Open djfurman opened 7 years ago
Generate or get UUIDS in NG or from API Gateway
Handle for jpg png, etc
@softEngJason Let me know if you need UUIDs from me
/s3-policy-document
endpoint created
Submit a GET request to this endpoint to get a one-time use response from the API gateway to securely upload a file into the bucket, includeing a query string for the filename
as whatever filename you want to use.
The API gateway will respond with this payload
{
"signature": "not_displaying_for_safety",
"encoded_policy": "not_displaying_for_safety",
"access_key": "not_displaying_for_safety",
"upload_url": "not_displaying_for_safety",
"key": "not_displaying_for_safety/[query-string-filename]"
}
When you are ready to upload, include these elements as form data. CORS has already been configured. The following example is BSD-2 licensed showing how to do it with jQuery (sorry I couldn't find something better)
var fd = new FormData();
fd.append('key', data.key)
fd.append('acl', 'private');
fd.append('Content-Type', file.type);
fd.append('AWSAccessKeyId', data.access_key);
fd.append('policy', data.encoded_policy)
fd.append('signature', data.signature);
fd.append('file', file, file.name);
$.ajax({
url: data.upload_url,
type: 'POST',
data: fd,
processData: false,
contentType: false,
xhr: this.progress,
beforeSend: function (req) {
req.setRequestHeader('Authorization', '');
}
}).done(function (response) {
that.uiElements.uploadButtonContainer.show();
that.uiElements.uploadProgressBar.hide();
alert('Uploaded Finished');
}).fail(function (response) {
that.uiElements.uploadButtonContainer.show();
that.uiElements.uploadProgressBar.hide();
alert('Failed to upload');
})
},
Post back an array of the key
s when you're ready for me to upload them for facial recognition with the filenames appended.
Given a random user AND a photo of that user When they upload the photos Then the photos should be stored in S3 AND named with UUIDS