I uploaded the file from S3direct
with this.
image = forms.URLField(widget=S3DirectWidget(dest='images'), required=False)
The file is uploaded correctly to S3 and log in the browser console
upload #1 getPayloadSha256Content: UNSIGNED-PAYLOAD
s3direct.js:44 upload #1 ETag: "47051d4d3084c578a0c48c79da8033e9"
s3direct.js:44 complete getPayloadSha256Content: 81808aac6435cb2f25f473c7724be92ffe85df80737de0bf2f06e48e7015aec2
s3direct.js:44 complete V4 CanonicalRequest: POST
/sai-s3-zance-up/a146387670074486a00e53e6027dfc7c/_origin.jpg
uploadId=PhMU_Aklz1TXpItHzGaTIoIlWXKgK5JkIktJO1OGYx4LCw2B17HB2c8fSByMLmNQbImVjaax3kMXWB9v5EyE8sFQnFHkwrU6s92w1mdrygf1sulUcNQmlZvOUf1cPZfyZt_HLFhMzVm.dfrIxjw.mg--
content-type:image/jpeg
host:s3.ap-northeast-1.amazonaws.com
x-amz-date:20220225T073518Z
content-type;host;x-amz-date
81808aac6435cb2f25f473c7724be92ffe85df80737de0bf2f06e48e7015aec2
s3direct.js:44 V4 stringToSign: AWS4-HMAC-SHA256
20220225T073518Z
20220225/ap-northeast-1/s3/aws4_request
72f75e6ab135be23a6bfb5090cff1d322c07476a3c3eb3822797309f1e9a9758
s3direct.js:44 complete signature: 4a30a45c817436877f38cc0cd4655fcfe6f3e93bf1283a48ddf8f064fd189b28
s3direct.js:44 complete getPayloadSha256Content: 81808aac6435cb2f25f473c7724be92ffe85df80737de0bf2f06e48e7015aec2
And content-type
is set as Content-Type image/jpeg
I can check also this on s3 aws-ui.
However when I click to the image url, it downloads.
Is there any reason other than Content-type
that the browser choose to download?
Where I should check?
CodePudding user response:
A probable issue is Content-Disposition. In your S3 upload, you should add:
ContentDisposition='inline'
This will set proper content disposition so it's viewed in the browser directly.