add support for AWS_PREFIX
This commit is contained in:
		
							parent
							
								
									05975d878a
								
							
						
					
					
						commit
						8c589c1ccd
					
				
					 1 changed files with 3 additions and 3 deletions
				
			
		| 
						 | 
					@ -13,14 +13,14 @@ class S3Storage(object):
 | 
				
			||||||
    def put(self, tracked_doc, data, content_type):
 | 
					    def put(self, tracked_doc, data, content_type):
 | 
				
			||||||
        """ upload the document to S3 """
 | 
					        """ upload the document to S3 """
 | 
				
			||||||
        k = boto.s3.key.Key(self.bucket)
 | 
					        k = boto.s3.key.Key(self.bucket)
 | 
				
			||||||
        k.key = tracked_doc['_id']
 | 
					        key_name = getattr(settings, AWS_PREFIX, '') + tracked_doc['_id']
 | 
				
			||||||
 | 
					        k.key = key_name
 | 
				
			||||||
        headers = {'x-amz-acl': 'public-read',
 | 
					        headers = {'x-amz-acl': 'public-read',
 | 
				
			||||||
                   'Content-Type': content_type}
 | 
					                   'Content-Type': content_type}
 | 
				
			||||||
        k.set_contents_from_string(data, headers=headers)
 | 
					        k.set_contents_from_string(data, headers=headers)
 | 
				
			||||||
        # can also set metadata if we want, useful?
 | 
					        # can also set metadata if we want, useful?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        url = 'http://%s.s3.amazonaws.com/%s' % (settings.AWS_BUCKET,
 | 
					        url = 'http://%s.s3.amazonaws.com/%s' % (settings.AWS_BUCKET, key_name)
 | 
				
			||||||
                                                 tracked_doc['_id'])
 | 
					 | 
				
			||||||
        return url
 | 
					        return url
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def get(self, id):
 | 
					    def get(self, id):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue