Skip to content

Instantly share code, notes, and snippets.

@gregblake
Created August 28, 2017 12:50
Show Gist options
  • Select an option

  • Save gregblake/795b0ab180d475129fb12d9146bf535a to your computer and use it in GitHub Desktop.

Select an option

Save gregblake/795b0ab180d475129fb12d9146bf535a to your computer and use it in GitHub Desktop.
$(document).on('page:update', function(){
$('#s3-uploader').fileupload();
$('#s3-uploader').fileupload(
'option',
{
// Send the request via PUT, rather than POST
type: 'put',
done: function (e, data) {
$(function () {
$.each(data.files, function (index, file) {
// retrieve the url of the newly uploaded attachment
var document_version_id = data._response.result.url;
// set the value of the s3_url hidden field to the url of the newly uploaded attachment
$("#s3_url").val(document_version_id);
});
});
return $("#territory-submit").prop('disabled', false);
},
start: function() {
return $("#territory-submit").prop('disabled', true);
},
stop: function() {
return $("#territory-submit").prop('disabled', false);
},
}
);
});
<form id="s3-uploader" data-callback-url="null" data-callback-method="POST" data-callback-param="file" enctype="multipart/form-data" action="https://s3-direct.powerhrg.com/nitro-devbox/" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="&#x2713;" />
<input type="hidden" name="key" id="key" value="greg_local_test{timestamp}-{unique_id}-b3f955bab1c9bec7d1aadeee5e802635/${filename}" />
<input type="hidden" name="acl" id="acl" value="public-read" /><input type="hidden" name="AWSAccessKeyId" id="AWSAccessKeyId" value="GWNQSVNDSVYEMTU6EFPD" />
<input type="hidden" name="policy" id="policy" value="eyJleHBpcmF0aW9uIjoiMjAxNy0wOC0yOFQyMjo0MzowNloiLCJjb25kaXRpb25zIjpbWyJzdGFydHMtd2l0aCIsIiR1dGY4IiwiIl0sWyJzdGFydHMtd2l0aCIsIiRrZXkiLCJncmVnX2xvY2FsX3Rlc3QiXSxbInN0YXJ0cy13aXRoIiwiJHgtcmVxdWVzdGVkLXdpdGgiLCIiXSxbImNvbnRlbnQtbGVuZ3RoLXJhbmdlIiwwLDUyNDI4ODAwMF0sWyJzdGFydHMtd2l0aCIsIiRjb250ZW50LXR5cGUiLCIiXSx7ImJ1Y2tldCI6Im5pdHJvLWRldmJveCJ9LHsiYWNsIjoicHVibGljLXJlYWQifSx7InN1Y2Nlc3NfYWN0aW9uX3N0YXR1cyI6IjIwMSJ9XX0=" /><input type="hidden" name="signature" id="signature" value="eIfe80K0wbI57/T845rvgJ04qio=" />
<input type="hidden" name="success_action_status" id="success_action_status" value="201" />
<input type="hidden" name="X-Requested-With" id="X-Requested-With" value="xhr" />
<input type="file" name="file" id="file" />
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment