def upload_chunks(io, path, options, upload=None, etags=None): if not etags: etags = [] bytes_written = 0 while True: headers = { "part": 1 } if not upload else { "ref": upload.ref, "part": upload.part_number + 1 } upload = file_action.begin_upload(path, headers, options)[0] buf = io.read(upload.partsize) if buf == b'' or buf == "": # Empty bytearray means EOF for BytesIO, Empty String means EOF for StringIO return (upload, etags, bytes_written) if buf is not None: # None means no data but io still open bytes_written += len(buf) response = Api.api_client().send_remote_request( upload.http_method, upload.upload_uri, {"Content-Length": str(len(buf))}, buf) if "ETag" in response.headers: etags.append({ "etag": response.headers["ETag"].strip('"'), "part": upload.part_number })
def download_content(self, io, is_string_io=False): Api.api_client().stream_download(self.download_uri_with_load(), io, is_string_io)