node-pushbullet-api icon indicating copy to clipboard operation
node-pushbullet-api copied to clipboard

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

Open davidnewcomb opened this issue 2 years ago • 0 comments

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

davidnewcomb avatar Aug 02 '23 16:08 davidnewcomb