Skip to content

Instantly share code, notes, and snippets.

@krusynth
Created April 1, 2014 20:35
Show Gist options
  • Save krusynth/9922603 to your computer and use it in GitHub Desktop.
Save krusynth/9922603 to your computer and use it in GitHub Desktop.
Example of sending custom headers using Pyrax.
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