Skip to content Skip to sidebar Skip to footer

Sending Binary Data To Amazon S3 (javascript)

Amazon S3 interprets my binary data as non-UTF-8 and modifies it when I write to a bucket. Example using the official s3 Javascript client: var png_file = new Buffer( 'iVBORw0KGgoA

Solution 1:

S3 putObject() assumes either a Buffer or an UTF-8 string. I should have sent the binary as it, not as a "binary string", meaning using new Buffer(...) instead of new Buffer(...).toString("binary").

Solution 2:

It seems unlikely that S3 is actually modifying the content you are uploading. It seems nore likely that it's being interpreted incorrectly on download, because this does not seem valid for a png:

ContentType:"text/data;charset=utf-8", 

That's not correct for a png file. I would suggest that this is what you want:

ContentType:"image/png", 

Post a Comment for "Sending Binary Data To Amazon S3 (javascript)"