Skip to content

Instantly share code, notes, and snippets.

@LeoQuote
Created August 28, 2020 06:30
Show Gist options
  • Save LeoQuote/f67a14636ac0931886c75dbfe3840840 to your computer and use it in GitHub Desktop.
Save LeoQuote/f67a14636ac0931886c75dbfe3840840 to your computer and use it in GitHub Desktop.
import boto3
from botocore.client import Config
s3 = boto3.resource(
's3',
# Hard coded strings as credentials, not recommended.
aws_access_key_id='',
aws_secret_access_key='',
endpoint_url='https://cos.ap-beijing.myqcloud.com',
config=Config(signature_version='s3v4')
)
bucket = s3.Bucket('bb')
key = bucket.Object('test')
key.put(Body='try try try', Metadata={
'python-version': '3.7',
'name': 'test',
'version': '1.0.1',
'Summary': "A super-fast templating language that borrows the best ideas from the existing templating languages.",
# 上面的summary 中 ideas from 中间有两个空格
})
k = bucket.Object('test')
print(k.get())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment