Fix upload Engine metafile to swift.

We need to pass the content length to swift in case of uploading
files, so we needed to calcuate the engine's metadata file size
and pass it to swift during upload.

Change-Id: I404401d0046c5aaff463043b82d40b48708b7149
This commit is contained in:
Saad Zaher 2016-11-29 18:02:23 +00:00
parent fec8995c84
commit 2a871b0690
1 changed files with 8 additions and 3 deletions

View File

@ -16,10 +16,13 @@ limitations under the License.
"""
import json
from oslo_log import log
import requests.exceptions
import os
import requests
import time
from oslo_log import log
from freezer.storage import physical
LOG = log.getLogger(__name__)
@ -42,8 +45,10 @@ class SwiftStorage(physical.PhysicalStorage):
def put_file(self, from_path, to_path):
self.client_manager.create_swift()
split = to_path.rsplit('/', 1)
file_size = os.path.getsize(from_path)
with open(from_path, 'r') as meta_fd:
self.swift().put_object(split[0], split[1], meta_fd)
self.swift().put_object(split[0], split[1], meta_fd,
content_length=file_size)
def __init__(self, client_manager, container, max_segment_size,
skip_prepare=False):