Last active
December 18, 2015 09:19
-
-
Save evan4498/5760758 to your computer and use it in GitHub Desktop.
Create temp url
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 | |
# -*- coding: utf-8 -*- | |
# Copyright 2013 Rackspace | |
# All Rights Reserved. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); you may | |
# not use this file except in compliance with the License. You may obtain | |
# a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | |
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | |
# License for the specific language governing permissions and limitations | |
# under the License. | |
import os | |
import sys | |
import pyrax | |
cls = pyrax.utils.import_class('pyrax.identity.rax_identity.RaxIdentity') | |
pyrax.identity = cls() | |
pyrax.set_credentials("USERNAME", "API_KEY") | |
cf = pyrax.cloudfiles | |
print "--------------------------------------------------" | |
cont = cf.get_container("iso") | |
files = cont.get_object_names() | |
for pos, filename in enumerate(files): | |
print "%s: %s" % (pos, filename) | |
print "" | |
filenum = int(raw_input("What file do you want to serve up? ")) | |
filename = files[filenum] | |
print "Serving file:", filename | |
print "" | |
time = int(raw_input("How many minutes should this file be served for? ")) | |
secs = time * 60 | |
print "" | |
my_key = "MAKE UP A KEY OF AT LEAST 10 LETTERS AND DIGITS" | |
cf.set_temp_url_key(my_key) | |
tempurl = cf.get_temp_url(cont.name, filename , seconds=secs, method="GET") | |
print "Temporary URL is: " | |
print tempurl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment