added original filename to uploaded log
This commit is contained in:
parent
c5a0aabeef
commit
9dac908f55
@ -96,7 +96,7 @@ class InternalProxy(object):
|
|||||||
|
|
||||||
def upload_file(self, source_file, account, container, object_name,
|
def upload_file(self, source_file, account, container, object_name,
|
||||||
compress=True, content_type='application/x-gzip',
|
compress=True, content_type='application/x-gzip',
|
||||||
etag=None):
|
etag=None, headers=None):
|
||||||
"""
|
"""
|
||||||
Upload a file to cloud files.
|
Upload a file to cloud files.
|
||||||
|
|
||||||
@ -115,10 +115,14 @@ class InternalProxy(object):
|
|||||||
if not self.create_container(account, container):
|
if not self.create_container(account, container):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
send_headers = {'Transfer-Encoding': 'chunked'}
|
||||||
|
if headers:
|
||||||
|
send_headers.update(headers)
|
||||||
|
|
||||||
# upload the file to the account
|
# upload the file to the account
|
||||||
req = webob.Request.blank(target_name, content_type=content_type,
|
req = webob.Request.blank(target_name, content_type=content_type,
|
||||||
environ={'REQUEST_METHOD': 'PUT'},
|
environ={'REQUEST_METHOD': 'PUT'},
|
||||||
headers={'Transfer-Encoding': 'chunked'})
|
headers=send_headers)
|
||||||
req.content_length = None # to make sure we send chunked data
|
req.content_length = None # to make sure we send chunked data
|
||||||
if etag:
|
if etag:
|
||||||
req.headers['etag'] = etag
|
req.headers['etag'] = etag
|
||||||
|
@ -184,11 +184,14 @@ class LogUploader(Daemon):
|
|||||||
# have unique filenames and protect against uploading one file
|
# have unique filenames and protect against uploading one file
|
||||||
# more than one time. By using md5, we get an etag for free.
|
# more than one time. By using md5, we get an etag for free.
|
||||||
target_filename = '/'.join([year, month, day, hour, filehash + '.gz'])
|
target_filename = '/'.join([year, month, day, hour, filehash + '.gz'])
|
||||||
|
metadata = {'x-object-meta-original-name': filename}
|
||||||
if self.internal_proxy.upload_file(filename,
|
if self.internal_proxy.upload_file(filename,
|
||||||
self.swift_account,
|
self.swift_account,
|
||||||
self.container_name,
|
self.container_name,
|
||||||
target_filename,
|
target_filename,
|
||||||
compress=(not already_compressed)):
|
compress=(not already_compressed),
|
||||||
|
etag=filehash,
|
||||||
|
headers=metadata):
|
||||||
self.logger.debug(_("Uploaded log %(file)s to %(target)s") %
|
self.logger.debug(_("Uploaded log %(file)s to %(target)s") %
|
||||||
{'file': filename, 'target': target_filename})
|
{'file': filename, 'target': target_filename})
|
||||||
if self.unlink_log:
|
if self.unlink_log:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user