We can construct a pre-approved HTTP POST form in the HTTP page to upload files to S3 using post in the browser side. The contents of the form are as follows:
where value= "Upload/${filename}" is the destination address, the directory automatically creates
Name= "Success_action_redirect value=" http:// Your-success-page ", after the successful upload of the jump page
name=" policy "value=" XXXX "with Base64 encrypted policy string
Name=" signature "value=" xxxx " , use the Base64 encrypted signature with Secret_key
Encryption algorithm is the following Python version:
Import Base64
import HMAC, hashlib
Aws_secret_access_key = r "xxxxxx"
policy_document = "'
{
" Expiration ":" 2020-01-01t00:00:00z ","
conditions ": [
{" Bucket ":" Your-bucket "},
[" Starts-with "," $ Key "," "],
{" ACL ":" Private "},
{" Success_action_redirect ":" Http://your-success-page "},
[" starts- With "," $Content-type "," "],
[" Content-length-range ", 0, 1048576000]
]
}
" '
policy = base6 4.b64encode (policy_document)
signature = Base64.b64encode (Hmac.new, Aws_secret_access_key, HASHLIB.SHA1). Digest ())
Print policy
print signature