123456789101112131415161718192021222324252627282930313233343536 |
- import boto
- from boto.s3.key import Key
- import urllib2, StringIO
- keyId = ""
- sKeyId= "/ZY0"
- fileName="abcd.txt"
- bucketName=""
- file = open(fileName)
- conn = boto.connect_s3(keyId,sKeyId)
- bucket = conn.get_bucket(bucketName)
- k = Key(bucket)
- url = ""
- k.key=url.split('/')[::-1][0]
- import pdb;pdb.set_trace()
- file_object = urllib2.urlopen(url)
- fp = StringIO.StringIO(file_object.read())
- k.set_contents_from_file(fp)
- k.set_acl('public-read')
- url = k.generate_url(expires_in=0, query_auth=False)
- print (url)
- from zipfile import ZipFile
- zipfile = ZipFile(file_object)
- zipfile = ZipFile(fp)
- zipfile.namelist()
- k.set_contents_from_file(StringIO.StringIO(zipfile.read('2.jpg')))
|