Фрагмент кода:
Код: Выделить всё
arc_name = 'test.zip'
zip_buffer = io.BytesIO()
with open zipfile.ZipFile(zip_buffer, "a", zipfile.ZIP_DEFLATED, True) as zip_file:
for file in files:
with open(file, 'rb') as src_file:
zip_file.writestr(arc_name, src_file.read())
Код: Выделить всё
zip_data = zip_buffer.getvalue()
checksum_base64 = base64.b64encode(hashlib.md5(zip_data).digest()).decode()
swift_conn = swiftclient.Connection()
container_name = 'swift-test'
swift_conn.put_object(container=container_name, contents=zip_data, content_type=None, obj=arc_name, etag=checksum_base64)
Код: Выделить всё
swiftclient.exceptions.ClientException: Object PUT failed: https://..../swift/v1/swift-test/test.zip 422 Unprocessable Entity
Если другой тип MIME более подходит или Я что-то еще упустил, буду благодарен за любую помощь.
Подробнее здесь: https://stackoverflow.com/questions/792 ... wiftclient
Мобильная версия