Created
October 21, 2013 21:21
-
-
Save clee/7091223 to your computer and use it in GitHub Desktop.
DreamObjects snippets for DreamScape article
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form action="https://promethean.objects.dreamhost.com/" method="POST" enctype="multipart/form-data"> | |
<input type="hidden" name="key" value="uploads/${filename}"> | |
<input type="hidden" name="AWSAccessKeyId" value="nr-q3_Rsprv94CdsuEpI"> | |
<input type="hidden" name="acl" value="private"> | |
<input type="hidden" name="success_action_redirect" value="http://c133.org/tmp/dho-success.html"> | |
<input type="hidden" name="policy" value="eyJleHBpcmF0aW9uIjogIjIwMTUtMDEtMDFUMDA6MDA6MDBaIiwKICAiY29uZGl0aW9ucyI6IFsKICAgIHsiYnVja2V0IjogImNsZWUifSwKICAgIFsic3RhcnRzLXdpdGgiLCAiJGtleSIsICJ1cGxvYWRzLyJdLAogICAgeyJhY2wiOiAicHJpdmF0ZSJ9LAogICAgeyJzdWNjZXNzX2FjdGlvbl9yZWRpcmVjdCI6ICJodHRwOi8vYzEzMy5vcmcvdG1wL2Roby1zdWNjZXNzLmh0bWwifSwKICAgIFsic3RhcnRzLXdpdGgiLCAiJENvbnRlbnQtVHlwZSIsICIiXQogIF0KfQo="> | |
<input type="hidden" name="signature" value="zYcruOMR6qr7o6/Syj001g/trms="> | |
<input type="hidden" name="Content-Type" value="image/jpeg"> | |
File to upload to DreamObjects: <input name="file" type="file"> | |
<input type="submit" value="Upload File to DreamObjects"> | |
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"expiration": "2015-01-01T00:00:00Z", | |
"conditions": [ | |
{"bucket": "promethean"}, | |
{"acl": "private"}, | |
{"success_action_redirect": "http://prometheus.objects.dreamhost.com/success.html"}, | |
["starts-with", "$key", "uploads/"], | |
["starts-with", "$Content-Type", ""], | |
["content-length-range", 1048576, 1048576000] | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import base64 | |
import hmac, hashlib | |
policy_document = open('policy.json', 'r').read() | |
policy = base64.b64encode(policy_document) | |
print("policy: {}\n\n".format(policy)) | |
DHO_SECRET_ACCESS_KEY = 'YOUR SECRET KEY HERE' | |
signature = base64.b64encode(hmac.new(DHO_SECRET_ACCESS_KEY, policy, hashlib.sha1).digest()) | |
print("signature: {}\n\n".format(signature)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment