⚲
Project
General
Profile
Sign in
Register
Home
Projects
Help
Search
:
rgw
All Projects
Ceph
»
rgw
Overview
Activity
Roadmap
Issues
Spent time
Gantt
Download (1015 Bytes)
Bug #22320
ยป copy-multipart-error.py
PL Garnier
, 12/05/2017 09:58 AM
#!/usr/bin/env python3
import
boto3
from
boto3.s3.transfer
import
TransferConfig
from
io
import
BytesIO
RGW_ENDPOINT
=
''
ACCESS_KEY
=
''
SECRET_KEY
=
''
BUCKET
=
'
COPY-MULTIPART-ERROR
'
SRC
=
'
src
'
DST
=
'
dst
'
CHUNK_SIZE
=
1024
s3client
=
boto3
.
client
(
'
s3
'
,
aws_access_key_id
=
ACCESS_KEY
,
aws_secret_access_key
=
SECRET_KEY
,
endpoint_url
=
RGW_ENDPOINT
)
tx_config
=
TransferConfig
(
multipart_threshold
=
CHUNK_SIZE
,
multipart_chunksize
=
CHUNK_SIZE
)
print
(
'
Creating bucket s3://{}
'
.
format
(
BUCKET
))
s3client
.
create_bucket
(
Bucket
=
BUCKET
)
print
(
'
Uploading s3://{}/{}
'
.
format
(
BUCKET
,
SRC
))
s3client
.
upload_fileobj
(
BytesIO
(
b
'
x
'
*
CHUNK_SIZE
),
BUCKET
,
SRC
,
Config
=
tx_config
)
print
(
'
Removing s3://{}/{}
'
.
format
(
BUCKET
,
DST
))
s3client
.
delete_object
(
Bucket
=
BUCKET
,
Key
=
DST
)
print
(
'
Copying s3://{}/{} to s3://{}/{}
'
.
format
(
BUCKET
,
SRC
,
BUCKET
,
DST
))
copy_source
=
{
'
Bucket
'
:
BUCKET
,
'
Key
'
:
SRC
,
}
s3client
.
copy
(
copy_source
,
BUCKET
,
DST
,
Config
=
tx_config
)
(1-1/1)
Loading...