Daniel-t / node-red-contrib-aws

A collection of Node-RED nodes for AWS.
Apache License 2.0
57 stars 59 forks source link

Issue with files downloaded or uploaded to S3 #12

Closed soumya-github closed 7 years ago

soumya-github commented 7 years ago

If files are downloaded using the GET method of the flow the files are getting corrupted. I tried with the below code also as said in the release. But it is not working. can you help. msg.payload=Buffer.from(msg.payload.Body).toString("utf-8")

ghost commented 7 years ago

I'm using it this way: var buf = new Buffer(msg.payload.Body, "utf-8").toString(); msg.payload=JSON.parse(buf); return msg;

Daniel-t commented 7 years ago

@soumya-github can you confirm the suggestion from @leonardobaiao solved your issue or not. Issue will close in 7 days otherwise.

Daniel-t commented 7 years ago

closed due to no response

bluepup commented 7 years ago

Had a similar problem while trying to upload a png file to s3. The file is in a buffer. When downloading the file the image is corrupted. Opening with a text editor shows {"type":"Buffer","data":[137,80,78,71,13,10,26,10,0,0, ...

bluepup commented 7 years ago

I see that it is expected behaviour, as the documentation for put says "stringifies msg.payload and stores it in s3://buckey/key". So sorry for the comment but I'm asking myself how to write binary files.

Daniel-t commented 7 years ago

I can't think of good a solution off the top of my head for this sorry.

One thing that might make it easier to use the uploaded file might be to base64encode the data prior to uploading, this will at least upload it in a standard encoding.