HTML Direct Upload Data to Amazon S3 Part 3: HTML Details (No Form)

Overview

We discuss the details about the HTML content (no form needed, signature, policy, .etc) which need to be sent back to browser for directly uploading data to Amazon S3.

HTML code

So HTML would be the direct client side, the general process is

1) user request the HTML page from our Application Server which is used to directly upload data to Amazon S3

2) we got the user request, and run the PHP code to general all the authenticate information the user needs to directly upload data and put all these information (signature, policy, access key) into the HTML as its content (secret key encrypted)

3) the user select file and click the button to call the javascript code to do the actual uploading.

The following is the HTML code:

<script type="text/javascript" language="javascript" src="Scripts/user_operations.js"></script>

<div id="directUploadsArea">
    <input type="hidden" name="accesskey" value="<?php echo $accesskey; ?>">
    <input type="hidden" name="policy" value="<?php echo $base64policy; ?>">
    <input type="hidden" name="signature" value="<?php echo $base64signature; ?>">
	<input type="file" id="fileS3">
	<input id="btnUploadS3" type="button" value="Upload To Amazon S3" onclick ="btnUploadS3_onclick()"/>
</div>

I will explain a bit more: So basically, there is nothing special for the HTML part, anyways, it is just a content holder, the real stuff would be done by javascript. and note we do not need the form structure and would let the javascript to send the request to Amazon S3 with all the associated authenticate information.

Remarks: There is a good advantage for not using form is that: we could only specify on destination URL in the form to which we send our request, if so, we do not have idea about which user upload which object into which places on Amazon S3. When all these things are handled by javascript, it could send all these tracking information to Amazon S3 and our Application Server respectively. That’s basically why i didn’t choose to use form to do so as the official documentation of Amazon S3 does.

Summary

Details about the HTML content (no form needed, signature, policy, .etc) which need to be sent back to browser for directly uploading data to Amazon S3 are given here and we do not adopt the form structure for the purpose of tracking user uploading information.

 


(Please specify the source  烟客旅人 sigmainfy — http://www.sigmainfy.com  as well as the original permalink

URL for any reprints,  and please do not use it for commercial purpose)

Written on October 7, 2014