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
Missing path on Readable stream #18
Comments
Hi @michalkvasnicak thanks for opening this. I'm definitely not opposed to exposing the Given these assumptions, I think that exposing the real file path would actually have undesirable effects. In my opinion, the form-data library should support appending of arbitrary streams (instead of special cases for fs and http) and allow manual specification of metadata like mimetype and size. What kind of problem are you trying to solve with this, if you don't mind me asking? |
@mike-marcacci yes you're right the should support arbitrary streams. What I'm trying to do is following:
For now I'm fixing that by providing just a filename to |
I have been hunting a bug where i'm trying to proxy a file upload. That being said, it seems like you may have pin pointed the issue @mike-marcacci - In my case, i noticed that value.path was set to an empty string - note that they are using fs-capacitor@^2.0.4. |
So after a little more digging, i found that there is a race condition in graphql-upload that is sometimes resolving before crypto.randomBytes or fs.open resolves. I patched thecode to be like this instead: capacitor.once('ready', () => upload.resolve(file)) Though there was another issue when used in combination with form-data. |
@gregory that is... very interesting to me. Is this something you can demonstrate? It should be safe to begin writing even before it's ready, since we wait internally: Lines 164 to 172 in a237676
If you've found a way to defeat this, I'd love to include it in the tests, as the timing and sequence of things in streams can vary across versions of node. |
OK, I believe I understand what you're getting at (and talked about it here). If that is incorrect, do let me know. From what I've been able to gather from all these issues is that basically the In a sense it's really fortunate that our I found the corresponding issue in the |
I was on the v2.0.4 but you are right as far as the race condition. |
I tried to use capacitor stream directly with
form-data
but there is nopath
property set on resulting stream causingform-data
to fail generating multipart/form-data request.https://nodejs.org/api/fs.html#fs_readstream_path
Data 1 returns length of
254
which is correct, data 2 returns221
.So if the stream should be compatible with file streams, it should set
path
property.https://github.com/form-data/form-data/blob/master/lib/form_data.js#L104
The text was updated successfully, but these errors were encountered: