aliyun / aliyun-oss-python-sdk

Aliyun OSS SDK for Python
MIT License
931 stars 363 forks source link

Consult: Can bucket be instantiated once and used continuously? #382

Open zengzzzzz opened 6 months ago

zengzzzzz commented 6 months ago
>>> import oss2
>>> auth = oss2.Auth('your-access-key-id', 'your-access-key-secret')
>>> bucket = oss2.Bucket(auth, 'http://oss-cn-hangzhou.aliyuncs.com', 'your-bucket')
>>> bucket.put_object('readme.txt', 'content of the object')
<oss2.models.PutObjectResult object at 0x029B9930>

In this example. can I Instantiate a bucket once and use it all the time. like this. and when the auth is sts auth. Thanks

>>> bucket = oss2.Bucket(auth, 'http://oss-cn-hangzhou.aliyuncs.com', 'your-bucket')
>>> bucket.put_object('readme1.txt', 'content of the object')
>>> bucket.put_object('readme2.txt', 'content of the object')
>>> bucket.put_object('readme3.txt', 'content of the object')