Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Christian Salzmann-Jaeckel
boto
Commits
60afe103
Commit
60afe103
authored
Aug 26, 2020
by
Christian Salzmann-Jaeckel
Browse files
add s3-upload-file.py
parent
2c80e2f4
Changes
1
Hide whitespace changes
Inline
Side-by-side
s3-upload-file.py
0 → 100755
View file @
60afe103
#!/usr/bin/python3
import
os
import
logging
import
boto3
radosgw_access_key
=
os
.
environ
[
'AWS_ACCESS_KEY_ID'
]
radosgw_secret_key
=
os
.
environ
[
'AWS_SECRET_ACCESS_KEY'
]
radosgw_endpoint_url
=
'https://rise-s3.zib.de'
radosgw_bucket_name
=
'py3-boto-bucket'
radosgw_key_name
=
'upload_file'
radosgw_file_name
=
'example.txt'
# generate s3 resource
s3_resource
=
boto3
.
resource
(
's3'
,
endpoint_url
=
radosgw_endpoint_url
,
aws_access_key_id
=
radosgw_access_key
,
aws_secret_access_key
=
radosgw_secret_key
)
# specity s3 bucket
bucket
=
s3_resource
.
Bucket
(
radosgw_bucket_name
)
# upload file
bucket
.
upload_file
(
Filename
=
radosgw_file_name
,
Key
=
radosgw_key_name
)
bucket_acl
=
s3_resource
.
BucketAcl
(
radosgw_bucket_name
)
response
=
bucket_acl
.
put
(
ACL
=
'public-read'
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment