amazonS3Extender.checkIntegrity Property HTML5/Flash Uploader JavaScript

Supported technologies:

Gets or sets a value indicating whether uploaded files should be checked for integrity or not.

Syntax

JavaScript Initialize
var u = $au.imageUploaderFlash({
    //...other params...
});
var as3 = $au.amazonS3Extender(u);
as3.checkIntegrity(false);
//...other params...
u.writeHtml();

Property Value

Type: Boolean

If true, each file will be uploaded along with its MD5 hash, so Amazon S3 can validate uploaded file before storing it. Otherwise, no hash values will be sent.

Default value is false.

Remarks

If you enabled integrity checking, you should add hash field to the policy:

C#
public string ConstructPolicy()
{
    StringBuilder policy = new StringBuilder();
    DateTime expDate = DateTime.Now.ToUniversalTime().AddSeconds(6000);

    policy.AppendLine("{ \"expiration\": \"" + expDate.ToString("s") + ".000Z\"");
    policy.AppendLine(", \"conditions\": [");
    policy.AppendLine(" {\"acl\": \"public-read\" }");
    policy.AppendLine(" , {\"bucket\": \"" + _bucket + "\" }");
    policy.AppendLine(" , {\"success_action_status\": \"200\"}");
    policy.AppendLine(" , [\"starts-with\", \"$key\", \"\"]");

    //Add hash field to the policy
    policy.AppendLine(" , [\"starts-with\", \"$Content-MD5\", \"\"]");

    policy.AppendLine("]");
    policy.AppendLine("}");

    // Encode the policy using UTF-8.
    byte[] bytes = Encoding.UTF8.GetBytes(policy.ToString());

    // Encode those UTF-8 bytes using Base64.
    return Convert.ToBase64String(bytes);
}

See Also

Reference