-
-
Notifications
You must be signed in to change notification settings - Fork 683
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add option to store files #666
feat: add option to store files #666
Conversation
Codecov Report
@@ Coverage Diff @@
## master #666 +/- ##
==========================================
- Coverage 82.05% 81.35% -0.70%
==========================================
Files 14 15 +1
Lines 652 692 +40
Branches 108 114 +6
==========================================
+ Hits 535 563 +28
- Misses 109 120 +11
- Partials 8 9 +1
Continue to review full report at Codecov.
|
6bf0db4
to
beb36d1
Compare
Could you make an example that shows how to use volatile file as an input to another http request body ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha, seems like a clever approach.
The only thing that bugs me every time and constantly forgetting "what's the difference between filename
and name
, what's the diff between type
and mime
? Is there a difference?". I think we should get rid of them, only filename
and mime
to remain? But that's probably for later, still for v2 tho.
README.md
Outdated
@@ -334,6 +334,8 @@ See it's defaults in [src/Formidable.js DEFAULT_OPTIONS](./src/Formidable.js) (t | |||
for incoming files, set this to some hash algorithm, see | |||
[crypto.createHash](https://nodejs.org/api/crypto.html#crypto_crypto_createhash_algorithm_options) | |||
for available algorithms | |||
- `options.storeFiles` **{boolean}** - default `true`; to store uploaded file(s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably add a hint in the features
section where we say "automatically writes to disk (optional soon)", something like "see options.storeFiles
?
@GrosSacASac not sure if I understand correctly what to do, it's to me add on README an example of usage of formidable to only parse files and store It? |
@tunnckoCore I think they all represent the same things, so there is no difference. But I think we should not change the code to have the same nomenclature in all places, because in the context of an HTTP request the |
Readme or in examples https://github.com/node-formidable/formidable/tree/master/examples |
c21ef44
beb36d1
to
c21ef44
Compare
@GrosSacASac and @tunnckoCore request changes are done :) |
How do you redirect the stream to something else other than a file ? With volatilefile ? How to overwrite the write () {} ? Or did I miss something. |
Not sure what you mean. You can get the file from |
|
To be clear: There are 2 thing this PR should do:
{ files } only contains file size and file names. May be add another option besides storeFiles
|
Or we can merge this now, and make another PR for part 2 |
Oh, I got it. Fair point. I think it would be better as part of this PR... I don't know. Merry Christmas 😉 |
0f627a7
to
ab1bf5b
Compare
f95b370
to
5b945cf
Compare
Hey, @tunnckoCore and @GrosSacASac sorry for the late response. I added changes to write the file to something else(cloud storages, stdout and etc...) I also added two examples of how to do this. I opted to maintain only one option because I don't see much value in having two options that are coupled.
|
4cdedf3
to
83c81e8
Compare
83c81e8
to
21d62c1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done
Was this functionality removed? |
No |
Description
This PR introduces changes to support stores in the host machine files uploaded. The new option
storeFiles
with default value astrue
determines it, iftrue
the files are parsed and stored, iffalse
the files are only parsed. Closes #609.Key Points
VolatileFile
andPersistentFile
, but in the end, I thought it was not worthy. Let me know what you think about it.