How to upload base64 image to aws s3 using putObject?

倾然丶 夕夏残阳落幕 提交于 2019-12-23 17:57:11

问题


I try to send base64 png image file to AWS s3 using putObject.

And I wonder that exactly what is payload?

payload = hash(base64Image) ?

here is a detail.

    $img = str_replace('data:image/png;base64,', '', $img);
    $img = str_replace(' ', '+', $img);

I returned that Message: S3::putObject(): [SignatureDoesNotMatch] The request signature we calculated does not match the signature you provided. Check your key and signing method.

Request

PUT /Bucketname/filename.png
x-amz-content-sha256=hash('sha256', $img)
x-amz-date=20160309T113423Z
Host=bucketname.s3-ap-northeast-2.amazonaws.com
Content-Type=image/png
Content-Encoding=base64 or not
Content-Length=120068
Auth~= AWS4...~

I used php-curl and not SDK, https://github.com/psugand/CodeIgniter-S3

I changed AUTH to AWS4 and test listBueckts();

what's problem?

来源:https://stackoverflow.com/questions/35890807/how-to-upload-base64-image-to-aws-s3-using-putobject

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!