Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Rackspace Cloud Files TempURL support #72

Closed
wants to merge 25 commits into from

Conversation

shawnps
Copy link

@shawnps shawnps commented Aug 7, 2012

No description provided.

return response.status in [httplib.OK, httplib.NO_CONTENT,
httplib.CREATED, httplib.ACCEPTED]

def ex_get_container_temp_url(self, container, method, timeout=60):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look at the docs (http://docs.rackspace.com/files/api/v1/cf-devguide/content/Create_TempURL-d1a444.html), you also need to specify an object prefix when creating a temp URL for a container.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw that, yeah. That's only for PUTs though, right? And I don't see where the prefix goes, is it a query param?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, documentation isn't totally cleared - would need to check the code.

Cloud Files account using \
ex_set_account_metadata_temp_url_key before \
you can use this method.")
hmac_body = "%s\n%s\n%s" % (method, expires, path)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style bike shed: use single quotes

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try:
key = self.ex_get_meta_data()['temp_url_key']
assert key is not None
except:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IRC, the correct Pythonic way is doing except Exception:

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

…_ex_get_object_temp_url_no_key_raises_key_error

from libcloud.utils.py3 import httplib
from libcloud.utils.py3 import urllib
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use libcloud.utils.py3.urlencode.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

container=container, meta_data=None,
driver=self)
exception_string = 'You must first set the X-Account-Meta-Temp-URL-Key header on your Cloud Files account using ex_set_account_metadata_temp_url_key before you can use this method.'
with self.assertRaisesRegexp(KeyError, exception_string):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not available in version < 2.7 so you can't do that.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kami
Copy link
Member

Kami commented Aug 8, 2012

Thanks. Merged into trunk (http://svn.apache.org/viewvc?view=revision&revision=1370664) with some changes:

  • Default method to GET
  • Fix the HMAC calculation so it works with Python 3.x

@Kami
Copy link
Member

Kami commented Sep 5, 2012

This has been merged, can you please close this PR?

@shawnps shawnps closed this Sep 5, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants