samedi 5 septembre 2015

Upload bytes or base64 string to s3 ruby sdk

I'm trying to upload an image to s3 using the ruby aws sdk. I'm able to upload the base64 string if I don't set the content_type. If I do set the content_type to image/png the upload is just the generic image thumbnail.

obj = #<Aws::S3::Object bucket_name="mybucket", key="test">

>> params[:file]
>> "data:image/png;base64,iVB...."

obj.put(body: params[:file], content_type: 'image/png', content_encoding: 'base64')

How can I upload a Base64 string to s3? I'm also open to uploading as bytes if that's more straight forward




Aucun commentaire:

Enregistrer un commentaire