def put_object_to_container(self, container_name,
file_path=None,
file_name=None,
file_stream=None):
"""
upload file to target container
:param container_name:
target container_name - string
required=True
:param file_path: file's path for upload - string
:param file_name: file's name for get urls - string
:param file_stream: file's data string - string
:return: submit response
"""
# make file object to comfortable for uploading
if not file_name:
file_name = file_path.split('/')[-1]
url = self.url + '/' + container_name + '/' + file_name
if not file_stream:
file_stream = open(file_path, 'rb').read()
response = requests.put(
url,
data=file_stream,
headers=self.base_headers
)
return response
评论列表
文章目录