Skip to content

File uploader was not handling stream object properly alexwhitman/nod…#50

Open
davidnewcomb wants to merge 1 commit intoalexwhitman:masterfrom
davidnewcomb:fix_send_file
Open

File uploader was not handling stream object properly alexwhitman/nod…#50
davidnewcomb wants to merge 1 commit intoalexwhitman:masterfrom
davidnewcomb:fix_send_file

Conversation

@davidnewcomb
Copy link

In pushes.js#70 you have:

formData.append('file', fs.createReadStream(filePath));

I think something has changed here. formData.append(name, x) expects a string here so fs.createReadStream(filePath) is toString()'ed to "[object Object]" and that is what the body of the request is.

There are some differences between native FormData and node-fetch FormData` and I think there might be some confusion here.

I have removed the streaming component part and replaced it with what was on the node-fetch website for handling file uploads using the File object. Now it works and I can see my pictures in the app.

When I was trying to get it to work last time there was also an issue with the file path not being found. I think that was something to do with streams not really knowing where they are from. Anyway, it only worked before if I didn't add a path to the file e.g. '1-jack.jpg' worked but '/path/to/1-jack.jpg' did not work. That appears to be fixed too (with this implementation).

Related to #49

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant