AWS S3 - Bucket policies with HTTP post
I'm currently following this AWS tutorial to try and let a client on my web app upload onto my S3 bucket. I have a POST policy as described on the tutorial (some details are redacted):
{ "expiration": "2019-12-30T12:00:00.000Z",
"conditions": [
{"bucket": "<MY BUCKET NAME>"},
["starts-with", "$key", "images/"],
{"acl": "public-read"},
["starts-with", "$Content-Type", "image/"],
{"x-amz-algorithm": "AWS4-HMAC-SHA256"},
{"x-amz-credential": "<AWSAccessKeyId>/20190101/eu-west-2/s3/aws4_request"},
{"x-amz-date": "20190101T000000Z" }
]
}
I have an HTML form as specified:
<form action="http://<bucket-name>.s3.amazonaws.com/" method="post" enctype="multipart/form-data">
Key to upload:
<input type="input" name="key" value="images/${filename}" /><br />
<input type="hidden" name="acl" value="public-read" />
Content-Type:
<input type="input" name="Content-Type" value="image/jpeg" /><br />
<input type="text" name="X-Amz-Credential" value="<AWSAccessKeyId>/20190101/eu-west-2/s3/aws4_request" />
<input type="text" name="X-Amz-Algorithm" value="AWS4-HMAC-SHA256" />
<input type="text" name="X-Amz-Date" value="20190101T000000Z" />
Tags for File:
<input type="input" name="x-amz-meta-tag" value="" /><br />
<input type="hidden" name="Policy" value='<MY BASE 64 policy>' />
<input type="hidden" name="X-Amz-Signature" value="<SIGNATURE-VALUE>" />
<!-- File: -->
<input type="file" name="file" /> <br />
<!-- The elements after this will be ignored -->
<input type="submit" name="submit" value="Upload to Amazon S3" />
</form>
As for my signature making code, I used their python example, and when I tested it with their string to sign and base 64 examples, I got the correct result. So I don't think my issue is there, but I can always upload my python code for that too.
However, when I try to submit this form and upload an image, I get a SignatureDoesNotMatch
error on the resulting XML page.
Am I supposed to upload the POST policy on my bucket permissions? I'm not sure how AWS calculates the signature as I don't think I've given it my policy. Am I just making a simple mistake?
amazon-web-services amazon-s3
add a comment |
I'm currently following this AWS tutorial to try and let a client on my web app upload onto my S3 bucket. I have a POST policy as described on the tutorial (some details are redacted):
{ "expiration": "2019-12-30T12:00:00.000Z",
"conditions": [
{"bucket": "<MY BUCKET NAME>"},
["starts-with", "$key", "images/"],
{"acl": "public-read"},
["starts-with", "$Content-Type", "image/"],
{"x-amz-algorithm": "AWS4-HMAC-SHA256"},
{"x-amz-credential": "<AWSAccessKeyId>/20190101/eu-west-2/s3/aws4_request"},
{"x-amz-date": "20190101T000000Z" }
]
}
I have an HTML form as specified:
<form action="http://<bucket-name>.s3.amazonaws.com/" method="post" enctype="multipart/form-data">
Key to upload:
<input type="input" name="key" value="images/${filename}" /><br />
<input type="hidden" name="acl" value="public-read" />
Content-Type:
<input type="input" name="Content-Type" value="image/jpeg" /><br />
<input type="text" name="X-Amz-Credential" value="<AWSAccessKeyId>/20190101/eu-west-2/s3/aws4_request" />
<input type="text" name="X-Amz-Algorithm" value="AWS4-HMAC-SHA256" />
<input type="text" name="X-Amz-Date" value="20190101T000000Z" />
Tags for File:
<input type="input" name="x-amz-meta-tag" value="" /><br />
<input type="hidden" name="Policy" value='<MY BASE 64 policy>' />
<input type="hidden" name="X-Amz-Signature" value="<SIGNATURE-VALUE>" />
<!-- File: -->
<input type="file" name="file" /> <br />
<!-- The elements after this will be ignored -->
<input type="submit" name="submit" value="Upload to Amazon S3" />
</form>
As for my signature making code, I used their python example, and when I tested it with their string to sign and base 64 examples, I got the correct result. So I don't think my issue is there, but I can always upload my python code for that too.
However, when I try to submit this form and upload an image, I get a SignatureDoesNotMatch
error on the resulting XML page.
Am I supposed to upload the POST policy on my bucket permissions? I'm not sure how AWS calculates the signature as I don't think I've given it my policy. Am I just making a simple mistake?
amazon-web-services amazon-s3
add a comment |
I'm currently following this AWS tutorial to try and let a client on my web app upload onto my S3 bucket. I have a POST policy as described on the tutorial (some details are redacted):
{ "expiration": "2019-12-30T12:00:00.000Z",
"conditions": [
{"bucket": "<MY BUCKET NAME>"},
["starts-with", "$key", "images/"],
{"acl": "public-read"},
["starts-with", "$Content-Type", "image/"],
{"x-amz-algorithm": "AWS4-HMAC-SHA256"},
{"x-amz-credential": "<AWSAccessKeyId>/20190101/eu-west-2/s3/aws4_request"},
{"x-amz-date": "20190101T000000Z" }
]
}
I have an HTML form as specified:
<form action="http://<bucket-name>.s3.amazonaws.com/" method="post" enctype="multipart/form-data">
Key to upload:
<input type="input" name="key" value="images/${filename}" /><br />
<input type="hidden" name="acl" value="public-read" />
Content-Type:
<input type="input" name="Content-Type" value="image/jpeg" /><br />
<input type="text" name="X-Amz-Credential" value="<AWSAccessKeyId>/20190101/eu-west-2/s3/aws4_request" />
<input type="text" name="X-Amz-Algorithm" value="AWS4-HMAC-SHA256" />
<input type="text" name="X-Amz-Date" value="20190101T000000Z" />
Tags for File:
<input type="input" name="x-amz-meta-tag" value="" /><br />
<input type="hidden" name="Policy" value='<MY BASE 64 policy>' />
<input type="hidden" name="X-Amz-Signature" value="<SIGNATURE-VALUE>" />
<!-- File: -->
<input type="file" name="file" /> <br />
<!-- The elements after this will be ignored -->
<input type="submit" name="submit" value="Upload to Amazon S3" />
</form>
As for my signature making code, I used their python example, and when I tested it with their string to sign and base 64 examples, I got the correct result. So I don't think my issue is there, but I can always upload my python code for that too.
However, when I try to submit this form and upload an image, I get a SignatureDoesNotMatch
error on the resulting XML page.
Am I supposed to upload the POST policy on my bucket permissions? I'm not sure how AWS calculates the signature as I don't think I've given it my policy. Am I just making a simple mistake?
amazon-web-services amazon-s3
I'm currently following this AWS tutorial to try and let a client on my web app upload onto my S3 bucket. I have a POST policy as described on the tutorial (some details are redacted):
{ "expiration": "2019-12-30T12:00:00.000Z",
"conditions": [
{"bucket": "<MY BUCKET NAME>"},
["starts-with", "$key", "images/"],
{"acl": "public-read"},
["starts-with", "$Content-Type", "image/"],
{"x-amz-algorithm": "AWS4-HMAC-SHA256"},
{"x-amz-credential": "<AWSAccessKeyId>/20190101/eu-west-2/s3/aws4_request"},
{"x-amz-date": "20190101T000000Z" }
]
}
I have an HTML form as specified:
<form action="http://<bucket-name>.s3.amazonaws.com/" method="post" enctype="multipart/form-data">
Key to upload:
<input type="input" name="key" value="images/${filename}" /><br />
<input type="hidden" name="acl" value="public-read" />
Content-Type:
<input type="input" name="Content-Type" value="image/jpeg" /><br />
<input type="text" name="X-Amz-Credential" value="<AWSAccessKeyId>/20190101/eu-west-2/s3/aws4_request" />
<input type="text" name="X-Amz-Algorithm" value="AWS4-HMAC-SHA256" />
<input type="text" name="X-Amz-Date" value="20190101T000000Z" />
Tags for File:
<input type="input" name="x-amz-meta-tag" value="" /><br />
<input type="hidden" name="Policy" value='<MY BASE 64 policy>' />
<input type="hidden" name="X-Amz-Signature" value="<SIGNATURE-VALUE>" />
<!-- File: -->
<input type="file" name="file" /> <br />
<!-- The elements after this will be ignored -->
<input type="submit" name="submit" value="Upload to Amazon S3" />
</form>
As for my signature making code, I used their python example, and when I tested it with their string to sign and base 64 examples, I got the correct result. So I don't think my issue is there, but I can always upload my python code for that too.
However, when I try to submit this form and upload an image, I get a SignatureDoesNotMatch
error on the resulting XML page.
Am I supposed to upload the POST policy on my bucket permissions? I'm not sure how AWS calculates the signature as I don't think I've given it my policy. Am I just making a simple mistake?
amazon-web-services amazon-s3
amazon-web-services amazon-s3
asked Jan 1 at 21:38
monadoboimonadoboi
3002315
3002315
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53999145%2faws-s3-bucket-policies-with-http-post%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53999145%2faws-s3-bucket-policies-with-http-post%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown