Created
April 1, 2014 20:35
-
-
Save krusynth/9922603 to your computer and use it in GitHub Desktop.
Example of sending custom headers using Pyrax.
This file contains hidden or 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
import config | |
import time | |
import uuid | |
import os | |
import pyrax | |
pyrax.set_setting("identity_type", "rackspace") | |
pyrax.set_setting("region", config.rackspace['API_REGION']) | |
def do_main_program() : | |
pyrax.set_credentials(config.rackspace['API_USERNAME'], config.rackspace['API_KEY']) | |
my_client_id = str(uuid.uuid4()) | |
cf = pyrax.cloudfiles | |
out_container = cf.get_container(config.rackspace['API_FILES_OUT']) | |
f = open('test.pdf', 'r') | |
# Upload the new file | |
obj = out_container.store_object('test.pdf', f.read(), | |
content_type='application/pdf', ttl=120, | |
headers={'Content-Disposition': 'inline; filename=test.pdf'}) | |
f.close() | |
print obj.get_temp_url(120) | |
do_main_program() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment