diff --git a/docs/obs_3rd_party/python_sdk/ALL_META.TXT.json b/docs/obs_3rd_party/python_sdk/ALL_META.TXT.json new file mode 100644 index 000000000..db284dd91 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/ALL_META.TXT.json @@ -0,0 +1,1823 @@ +[ + { + "dockw":"Python SDK Developer Guide" + }, + { + "uri":"obs_22_0001.html", + "node_id":"obs_22_0001.xml", + "product_code":"obs", + "code":"1", + "des":"This section describes the important notes about Object Storage Service (OBS) SDK for Python.Some features are available only in some regions. If 405 HTTP status code is ", + "doc_type":"sdk-python-devg", + "kw":"Before You Start (SDK for Python),Python SDK Developer Guide", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Before You Start (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0100.html", + "node_id":"obs_22_0100.xml", + "product_code":"obs", + "code":"2", + "des":"Table 1 describes the APIs provided by OBS SDK for Python. You can click an API name in the table to see its detailed information and sample code.", + "doc_type":"sdk-python-devg", + "kw":"API Overview of OBS SDK for Python,Python SDK Developer Guide", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"API Overview of OBS SDK for Python", + "githuburl":"" + }, + { + "uri":"obs_22_0300.html", + "node_id":"obs_22_0300.xml", + "product_code":"obs", + "code":"3", + "des":"Before using OBS SDK for Python to access OBS, you need to prepare the service and development environments. To prepare the service environment, you must get an account a", + "doc_type":"sdk-python-devg", + "kw":"Preparations (SDK for Python),Python SDK Developer Guide", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Preparations (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0400.html", + "node_id":"obs_22_0400.xml", + "product_code":"obs", + "code":"4", + "des":"This topic provides the download links and installation methods of OBS SDK for Python.Latest version of OBS Python SDK source code: DownloadYou can use the methods listed", + "doc_type":"sdk-python-devg", + "kw":"Downloading and Installing OBS SDK for Python,Python SDK Developer Guide", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Downloading and Installing OBS SDK for Python", + "githuburl":"" + }, + { + "uri":"obs_22_0500.html", + "node_id":"obs_22_0500.xml", + "product_code":"obs", + "code":"5", + "des":"OBS employs access keys (AK and SK) for signature verification to ensure that only authorized accounts can access specified OBS resources. Detailed explanations of access", + "doc_type":"sdk-python-devg", + "kw":"Getting Started with OBS SDK for Python,Python SDK Developer Guide", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Getting Started with OBS SDK for Python", + "githuburl":"" + }, + { + "uri":"obs_22_0600.html", + "node_id":"obs_22_0600.xml", + "product_code":"obs", + "code":"6", + "des":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "doc_type":"sdk-python-devg", + "kw":"Initialization (SDK for Python)", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Initialization (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0601.html", + "node_id":"obs_22_0601.xml", + "product_code":"obs", + "code":"7", + "des":"ObsClient functions as the Python client for accessing OBS. It offers users a series of APIs for interaction with OBS. These APIs are used for managing resources, such as", + "doc_type":"sdk-python-devg", + "kw":"Initializing an Instance of ObsClient (SDK for Python),Initialization (SDK for Python),Python SDK De", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Initializing an Instance of ObsClient (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0602.html", + "node_id":"obs_22_0602.xml", + "product_code":"obs", + "code":"8", + "des":"BucketClient functions as the Python client for accessing an OBS bucket. It offers users a series of APIs for interaction with OBS. These APIs are used for managing resou", + "doc_type":"sdk-python-devg", + "kw":"Initializing a BucketClient Instance (SDK for Python),Initialization (SDK for Python),Python SDK Dev", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Initializing a BucketClient Instance (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0603.html", + "node_id":"obs_22_0603.xml", + "product_code":"obs", + "code":"9", + "des":"You can enable the SDK log function to record log information generated during API calling into log files for subsequent data analysis or fault location. The procedure is", + "doc_type":"sdk-python-devg", + "kw":"Log Initialization (SDK for Python),Initialization (SDK for Python),Python SDK Developer Guide", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Log Initialization (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0604.html", + "node_id":"obs_22_0604.xml", + "product_code":"obs", + "code":"10", + "des":"Each time an ObsClient related API is called (excluding ObsClient.createSignedUrl and ObsClient.createPostSignature), an SDK common result object will be returned. You ca", + "doc_type":"sdk-python-devg", + "kw":"SDK Common Results (SDK for Python),Initialization (SDK for Python),Python SDK Developer Guide", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"SDK Common Results (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0800.html", + "node_id":"obs_22_0800.xml", + "product_code":"obs", + "code":"11", + "des":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "doc_type":"sdk-python-devg", + "kw":"Bucket-Related APIs (SDK for Python)", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Bucket-Related APIs (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0801.html", + "node_id":"obs_22_0801.xml", + "product_code":"obs", + "code":"12", + "des":"This API creates an OBS bucket. Buckets are containers for storing objects (files uploaded to OBS) in OBS.When creating a bucket, you can also configure parameters such a", + "doc_type":"sdk-python-devg", + "kw":"Creating a Bucket (SDK for Python),Bucket-Related APIs (SDK for Python),Python SDK Developer Guide", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Creating a Bucket (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0802.html", + "node_id":"obs_22_0802.xml", + "product_code":"obs", + "code":"13", + "des":"OBS buckets are containers for storing objects you upload to OBS. This API returns a list of all buckets that meet the specified conditions in all regions of the current ", + "doc_type":"sdk-python-devg", + "kw":"Obtaining a Bucket List (SDK for Python),Bucket-Related APIs (SDK for Python),Python SDK Developer G", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Obtaining a Bucket List (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0803.html", + "node_id":"obs_22_0803.xml", + "product_code":"obs", + "code":"14", + "des":"This API checks whether a bucket exists. If an HTTP status code 200 is returned, the bucket exists. If 404 is returned, the bucket does not exist.To determine whether a b", + "doc_type":"sdk-python-devg", + "kw":"Checking Whether a Bucket Exists (SDK for Python),Bucket-Related APIs (SDK for Python),Python SDK De", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Checking Whether a Bucket Exists (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0804.html", + "node_id":"obs_22_0804.xml", + "product_code":"obs", + "code":"15", + "des":"This API deletes an empty bucket. You can delete buckets you no longer use to free up space. The name of a deleted bucket can be reused for another bucket at least 30 min", + "doc_type":"sdk-python-devg", + "kw":"Deleting a Bucket (SDK for Python),Bucket-Related APIs (SDK for Python),Python SDK Developer Guide", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Deleting a Bucket (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0805.html", + "node_id":"obs_22_0805.xml", + "product_code":"obs", + "code":"16", + "des":"This API lists some or all of the objects in a bucket. You can use parameters such as the prefix, number of returned objects, and start position to list objects that meet", + "doc_type":"sdk-python-devg", + "kw":"Listing Objects in a Bucket (SDK for Python),Bucket-Related APIs (SDK for Python),Python SDK Develop", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Listing Objects in a Bucket (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0806.html", + "node_id":"obs_22_0806.xml", + "product_code":"obs", + "code":"17", + "des":"This API lists some or all of the object versions in a bucket. You can use parameters such as the prefix, number of returned object versions, and start position to list t", + "doc_type":"sdk-python-devg", + "kw":"Listing Object Versions in a Bucket (SDK for Python),Bucket-Related APIs (SDK for Python),Python SDK", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Listing Object Versions in a Bucket (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0807.html", + "node_id":"obs_22_0807.xml", + "product_code":"obs", + "code":"18", + "des":"This API returns information about a bucket, including the storage class, region, CORS rules, and redundancy policy.To obtain bucket metadata, you must be the bucket owne", + "doc_type":"sdk-python-devg", + "kw":"Obtaining Bucket Metadata (SDK for Python),Bucket-Related APIs (SDK for Python),Python SDK Developer", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Obtaining Bucket Metadata (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0808.html", + "node_id":"obs_22_0808.xml", + "product_code":"obs", + "code":"19", + "des":"This API returns the region of a bucket.To obtain the region of a bucket, you must be the bucket owner or have the required permission (obs:bucket:GetBucketLocation in IA", + "doc_type":"sdk-python-devg", + "kw":"Obtaining the Region of a Bucket (SDK for Python),Bucket-Related APIs (SDK for Python),Python SDK De", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Obtaining the Region of a Bucket (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0809.html", + "node_id":"obs_22_0809.xml", + "product_code":"obs", + "code":"20", + "des":"This API returns the storage information of a bucket, including the number of objects and the space occupied by the objects in the bucket.OBS measures bucket storage stat", + "doc_type":"sdk-python-devg", + "kw":"Obtaining Storage Information of a Bucket (SDK for Python),Bucket-Related APIs (SDK for Python),Pyth", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Obtaining Storage Information of a Bucket (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0810.html", + "node_id":"obs_22_0810.xml", + "product_code":"obs", + "code":"21", + "des":"A quota limits the maximum capacity allowed in a bucket. By default, there is no limit on the storage capacity of the entire OBS system or a single bucket, and any number", + "doc_type":"sdk-python-devg", + "kw":"Configuring a Storage Quota (SDK for Python),Bucket-Related APIs (SDK for Python),Python SDK Develop", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Configuring a Storage Quota (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0811.html", + "node_id":"obs_22_0811.xml", + "product_code":"obs", + "code":"22", + "des":"This API returns the storage quota (upper limit of the storage capacity) of a bucket. If the quota is 0, there is no upper limit on the bucket capacity.A bucket storage q", + "doc_type":"sdk-python-devg", + "kw":"Obtaining a Bucket Storage Quota (SDK for Python),Bucket-Related APIs (SDK for Python),Python SDK De", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Obtaining a Bucket Storage Quota (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0812.html", + "node_id":"obs_22_0812.xml", + "product_code":"obs", + "code":"23", + "des":"This API configures a storage class for a bucket. If you do not specify a storage class when uploading or copying an object, or initiating a multipart upload, the object ", + "doc_type":"sdk-python-devg", + "kw":"Configuring a Storage Class for a Bucket (SDK for Python),Bucket-Related APIs (SDK for Python),Pytho", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Configuring a Storage Class for a Bucket (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0813.html", + "node_id":"obs_22_0813.xml", + "product_code":"obs", + "code":"24", + "des":"This API returns the storage class of a bucket.To obtain a bucket's storage class, you must be the bucket owner or have the required permission (obs:bucket:GetBucketStora", + "doc_type":"sdk-python-devg", + "kw":"Obtaining the Storage Class of a Bucket (SDK for Python),Bucket-Related APIs (SDK for Python),Python", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Obtaining the Storage Class of a Bucket (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0814.html", + "node_id":"obs_22_0814.xml", + "product_code":"obs", + "code":"25", + "des":"OBS provides access control over buckets. You can use an access policy to define whether a user can perform certain operations on a specific bucket. OBS access control ca", + "doc_type":"sdk-python-devg", + "kw":"Configuring a Bucket ACL (SDK for Python),Bucket-Related APIs (SDK for Python),Python SDK Developer ", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Configuring a Bucket ACL (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0815.html", + "node_id":"obs_22_0815.xml", + "product_code":"obs", + "code":"26", + "des":"OBS provides access control over buckets. You can use an access policy to define whether a user can perform certain operations on a specific bucket. OBS access control ca", + "doc_type":"sdk-python-devg", + "kw":"Obtaining a Bucket ACL (SDK for Python),Bucket-Related APIs (SDK for Python),Python SDK Developer Gu", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Obtaining a Bucket ACL (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0816.html", + "node_id":"obs_22_0816.xml", + "product_code":"obs", + "code":"27", + "des":"This API enables logging for a bucket (source) and configures another bucket (target) to store the log files. When a bucket is created, logging is not enabled by default.", + "doc_type":"sdk-python-devg", + "kw":"Configuring Logging for a Bucket (SDK for Python),Bucket-Related APIs (SDK for Python),Python SDK De", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Configuring Logging for a Bucket (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0817.html", + "node_id":"obs_22_0817.xml", + "product_code":"obs", + "code":"28", + "des":"This API returns the logging configuration of a bucket.To obtain the logging configuration of a bucket, you must be the bucket owner or have the required permission (obs:", + "doc_type":"sdk-python-devg", + "kw":"Obtaining the Logging Configuration of a Bucket (SDK for Python),Bucket-Related APIs (SDK for Python", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Obtaining the Logging Configuration of a Bucket (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0818.html", + "node_id":"obs_22_0818.xml", + "product_code":"obs", + "code":"29", + "des":"OBS provides access control over buckets. You can use an access policy to define whether a user can perform certain operations on a specific bucket. OBS access control ca", + "doc_type":"sdk-python-devg", + "kw":"Configuring a Bucket Policy (SDK for Python),Bucket-Related APIs (SDK for Python),Python SDK Develop", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Configuring a Bucket Policy (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0819.html", + "node_id":"obs_22_0819.xml", + "product_code":"obs", + "code":"30", + "des":"OBS provides access control over buckets. You can use an access policy to define whether a user can perform certain operations on a specific bucket. OBS access control ca", + "doc_type":"sdk-python-devg", + "kw":"Obtaining the Policy of a Bucket (SDK for Python),Bucket-Related APIs (SDK for Python),Python SDK De", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Obtaining the Policy of a Bucket (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0820.html", + "node_id":"obs_22_0820.xml", + "product_code":"obs", + "code":"31", + "des":"OBS provides access control over buckets. You can use an access policy to define whether a user can perform certain operations on a specific bucket. OBS access control ca", + "doc_type":"sdk-python-devg", + "kw":"Deleting a Bucket Policy (SDK for Python),Bucket-Related APIs (SDK for Python),Python SDK Developer ", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Deleting a Bucket Policy (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0821.html", + "node_id":"obs_22_0821.xml", + "product_code":"obs", + "code":"32", + "des":"You can configure lifecycle rules to periodically delete objects or transition objects between storage classes.This API configures lifecycle rules for a bucket.Expired ob", + "doc_type":"sdk-python-devg", + "kw":"Configuring Lifecycle Rules for a Bucket (SDK for Python),Bucket-Related APIs (SDK for Python),Pytho", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Configuring Lifecycle Rules for a Bucket (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0822.html", + "node_id":"obs_22_0822.xml", + "product_code":"obs", + "code":"33", + "des":"You can configure lifecycle rules to periodically delete objects or transition objects between storage classes.This API returns the lifecycle rules of a bucket.To obtain ", + "doc_type":"sdk-python-devg", + "kw":"Obtaining the Lifecycle Configuration of a Bucket (SDK for Python),Bucket-Related APIs (SDK for Pyth", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Obtaining the Lifecycle Configuration of a Bucket (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0823.html", + "node_id":"obs_22_0823.xml", + "product_code":"obs", + "code":"34", + "des":"You can configure lifecycle rules to periodically delete objects or transition objects between storage classes.This API deletes the lifecycle configuration of a bucket.To", + "doc_type":"sdk-python-devg", + "kw":"Deleting the Lifecycle Configuration of a Bucket (SDK for Python),Bucket-Related APIs (SDK for Pytho", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Deleting the Lifecycle Configuration of a Bucket (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0824.html", + "node_id":"obs_22_0824.xml", + "product_code":"obs", + "code":"35", + "des":"You can host static website resources such as HTML web pages, flash files, or audio and video files in an OBS bucket, so that you can provide these hosted resources using", + "doc_type":"sdk-python-devg", + "kw":"Configuring Static Website Hosting for a Bucket (SDK for Python),Bucket-Related APIs (SDK for Python", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Configuring Static Website Hosting for a Bucket (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0825.html", + "node_id":"obs_22_0825.xml", + "product_code":"obs", + "code":"36", + "des":"You can host static website resources such as HTML web pages, flash files, as well as audio and video files in an OBS bucket, so that you can provide these hosted resourc", + "doc_type":"sdk-python-devg", + "kw":"Obtaining Static Website Hosting for a Bucket (SDK for Python),Bucket-Related APIs (SDK for Python),", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Obtaining Static Website Hosting for a Bucket (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0826.html", + "node_id":"obs_22_0826.xml", + "product_code":"obs", + "code":"37", + "des":"You can host static website resources such as HTML web pages, flash files, as well as audio and video files in an OBS bucket, so that you can provide these hosted resourc", + "doc_type":"sdk-python-devg", + "kw":"Deleting Static Website Hosting for a Bucket (SDK for Python),Bucket-Related APIs (SDK for Python),P", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Deleting Static Website Hosting for a Bucket (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0827.html", + "node_id":"obs_22_0827.xml", + "product_code":"obs", + "code":"38", + "des":"You can enable versioning to automatically maintain previous versions of an object. When versioning is enabled, you can access earlier versions of an object to recover yo", + "doc_type":"sdk-python-devg", + "kw":"Configuring Versioning for a Bucket (SDK for Python),Bucket-Related APIs (SDK for Python),Python SDK", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Configuring Versioning for a Bucket (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0828.html", + "node_id":"obs_22_0828.xml", + "product_code":"obs", + "code":"39", + "des":"You can enable versioning to automatically maintain previous versions of an object. When versioning is enabled, you can access earlier versions of an object to recover yo", + "doc_type":"sdk-python-devg", + "kw":"Obtaining the Versioning Status of a Bucket (SDK for Python),Bucket-Related APIs (SDK for Python),Py", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Obtaining the Versioning Status of a Bucket (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0829.html", + "node_id":"obs_22_0829.xml", + "product_code":"obs", + "code":"40", + "des":"Cross-origin resource sharing (CORS) is a mechanism defined by the World Wide Web Consortium (W3C) that allows a web application program in one domain to access resources", + "doc_type":"sdk-python-devg", + "kw":"Configuring CORS for a Bucket (SDK for Python),Bucket-Related APIs (SDK for Python),Python SDK Devel", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Configuring CORS for a Bucket (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0830.html", + "node_id":"obs_22_0830.xml", + "product_code":"obs", + "code":"41", + "des":"Cross-origin resource sharing (CORS) is a mechanism defined by the World Wide Web Consortium (W3C) that allows a web application program in one domain to access resources", + "doc_type":"sdk-python-devg", + "kw":"Obtaining the CORS Configuration of a Bucket (SDK for Python),Bucket-Related APIs (SDK for Python),P", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Obtaining the CORS Configuration of a Bucket (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0831.html", + "node_id":"obs_22_0831.xml", + "product_code":"obs", + "code":"42", + "des":"Cross-origin resource sharing (CORS) is a mechanism defined by the World Wide Web Consortium (W3C) that allows a web application program in one domain to access resources", + "doc_type":"sdk-python-devg", + "kw":"Deleting the CORS Configuration of a Bucket (SDK for Python),Bucket-Related APIs (SDK for Python),Py", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Deleting the CORS Configuration of a Bucket (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0834.html", + "node_id":"obs_22_0834.xml", + "product_code":"obs", + "code":"43", + "des":"If you add tags to a bucket, SDRs generated for the requests sent to this bucket will include these tags, so you can use the tags to classify SDRs for detailed cost analy", + "doc_type":"sdk-python-devg", + "kw":"Configuring Tags for a Bucket (SDK for Python),Bucket-Related APIs (SDK for Python),Python SDK Devel", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Configuring Tags for a Bucket (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0835.html", + "node_id":"obs_22_0835.xml", + "product_code":"obs", + "code":"44", + "des":"If you add tags to a bucket, SDRs generated for the requests sent to this bucket will include these tags, so you can use the tags to classify SDRs for detailed cost analy", + "doc_type":"sdk-python-devg", + "kw":"Obtaining Bucket Tags (SDK for Python),Bucket-Related APIs (SDK for Python),Python SDK Developer Gui", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Obtaining Bucket Tags (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0836.html", + "node_id":"obs_22_0836.xml", + "product_code":"obs", + "code":"45", + "des":"If you add tags to a bucket, SDRs generated for the requests sent to this bucket will include these tags, so you can use the tags to classify SDRs for detailed cost analy", + "doc_type":"sdk-python-devg", + "kw":"Deleting Bucket Tags (SDK for Python),Bucket-Related APIs (SDK for Python),Python SDK Developer Guid", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Deleting Bucket Tags (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0900.html", + "node_id":"obs_22_0900.xml", + "product_code":"obs", + "code":"46", + "des":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "doc_type":"sdk-python-devg", + "kw":"Object-Related APIs (SDK for Python)", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Object-Related APIs (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0501.html", + "node_id":"obs_22_0501.xml", + "product_code":"obs", + "code":"47", + "des":"You can use this API to upload an object to a specified bucket. In OBS, objects are basic data units that you can operate. OBS Python SDK provides many APIs for uploading", + "doc_type":"sdk-python-devg", + "kw":"Object Upload Overview (SDK for Python),Object-Related APIs (SDK for Python),Python SDK Developer Gu", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Object Upload Overview (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0901.html", + "node_id":"obs_22_0901.xml", + "product_code":"obs", + "code":"48", + "des":"This API uploads the text using strings as the data source to a specified bucket.To upload an object, you must be the bucket owner or have the required permission (obs:ob", + "doc_type":"sdk-python-devg", + "kw":"Uploading Objects - Text-Based (SDK for Python),Object-Related APIs (SDK for Python),Python SDK Deve", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Uploading Objects - Text-Based (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0902.html", + "node_id":"obs_22_0902.xml", + "product_code":"obs", + "code":"49", + "des":"You can upload texts, images, videos, or any other types of files smaller than 5 GB.Streaming upload uses readable objects that contain the read attribute as the data sou", + "doc_type":"sdk-python-devg", + "kw":"Uploading an Object - Streaming (SDK for Python),Object-Related APIs (SDK for Python),Python SDK Dev", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Uploading an Object - Streaming (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0903.html", + "node_id":"obs_22_0903.xml", + "product_code":"obs", + "code":"50", + "des":"This API uploads local filesto OBS over the Internet. These files can be texts, images, videos, or any other type of files.OBS does not involve folders like in a file sys", + "doc_type":"sdk-python-devg", + "kw":"Uploading an Object - File-Based (SDK for Python),Object-Related APIs (SDK for Python),Python SDK De", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Uploading an Object - File-Based (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0904.html", + "node_id":"obs_22_0904.xml", + "product_code":"obs", + "code":"51", + "des":"This API uploads a file or folder to an existing OBS bucket. These files can be texts, images, videos, or any other type of files.The AppendObject operation adds data to ", + "doc_type":"sdk-python-devg", + "kw":"Uploading an Object - Append (SDK for Python),Object-Related APIs (SDK for Python),Python SDK Develo", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Uploading an Object - Append (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0905.html", + "node_id":"obs_22_0905.xml", + "product_code":"obs", + "code":"52", + "des":"The resumable upload is an encapsulated and enhanced version of the multipart upload used for dealing with possible upload failures of large files when the network connec", + "doc_type":"sdk-python-devg", + "kw":"Uploading an Object - Resumable (SDK for Python),Object-Related APIs (SDK for Python),Python SDK Dev", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Uploading an Object - Resumable (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0906.html", + "node_id":"obs_22_0906.xml", + "product_code":"obs", + "code":"53", + "des":"You can query the upload progress when uploading an object in streaming, file-based, multipart, appendable, or resumable mode.This example configures a callback function ", + "doc_type":"sdk-python-devg", + "kw":"Obtaining the Upload Progress (SDK for Python),Object-Related APIs (SDK for Python),Python SDK Devel", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Obtaining the Upload Progress (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0907.html", + "node_id":"obs_22_0907.xml", + "product_code":"obs", + "code":"54", + "des":"This API uploads an object up to 5 GB to a specified bucket in HTML form. You can call ObsClient.createPostSignature to generate parameters for requesting a browser-based", + "doc_type":"sdk-python-devg", + "kw":"Uploading an Object - Browser-Based (SDK for Python),Object-Related APIs (SDK for Python),Python SDK", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Uploading an Object - Browser-Based (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0502.html", + "node_id":"obs_22_0502.xml", + "product_code":"obs", + "code":"55", + "des":"OBS Python SDK provides abundant APIs for downloading objects using various methods:Binary DownloadStreaming DownloadFile-Based DownloadPartial DownloadResumable Download", + "doc_type":"sdk-python-devg", + "kw":"Object Download Overview (SDK for Python),Object-Related APIs (SDK for Python),Python SDK Developer ", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Object Download Overview (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0908.html", + "node_id":"obs_22_0908.xml", + "product_code":"obs", + "code":"56", + "des":"This API downloads an object in binary from OBS to your local computer.To download an object, you must be the bucket owner or have the required permission (obs:object:Get", + "doc_type":"sdk-python-devg", + "kw":"Downloading an Object - Binary (SDK for Python),Object-Related APIs (SDK for Python),Python SDK Deve", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Downloading an Object - Binary (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0909.html", + "node_id":"obs_22_0909.xml", + "product_code":"obs", + "code":"57", + "des":"This API downloads an object using streaming from OBS to your local computer.To download an object, you must be the bucket owner or have the required permission (obs:obje", + "doc_type":"sdk-python-devg", + "kw":"Downloading an Object - Streaming (SDK for Python),Object-Related APIs (SDK for Python),Python SDK D", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Downloading an Object - Streaming (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0910.html", + "node_id":"obs_22_0910.xml", + "product_code":"obs", + "code":"58", + "des":"This API downloads an object as a file from OBS to your local computer.To download an object, you must be the bucket owner or have the required permission (obs:object:Get", + "doc_type":"sdk-python-devg", + "kw":"Downloading an Object - File-Based (SDK for Python),Object-Related APIs (SDK for Python),Python SDK ", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Downloading an Object - File-Based (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0911.html", + "node_id":"obs_22_0911.xml", + "product_code":"obs", + "code":"59", + "des":"This API downloads partial data of an object by specifying a range. If the specified range is from 0 to 1,000, data from byte 0 to byte 1,000, 1,001 bytes in total, are r", + "doc_type":"sdk-python-devg", + "kw":"Downloading an Object - Range-Based (SDK for Python),Object-Related APIs (SDK for Python),Python SDK", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Downloading an Object - Range-Based (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0912.html", + "node_id":"obs_22_0912.xml", + "product_code":"obs", + "code":"60", + "des":"Downloading large files often fails due to unstable network or program breakdown. It is a waste of resources to download files again. Moreover, the restarted download may", + "doc_type":"sdk-python-devg", + "kw":"Downloading an Object - Resumable (SDK for Python),Object-Related APIs (SDK for Python),Python SDK D", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Downloading an Object - Resumable (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0913.html", + "node_id":"obs_22_0913.xml", + "product_code":"obs", + "code":"61", + "des":"You can obtain the download progress when downloading an object in binary, streaming, file-based, or resumable mode.This example returns the object download progress.Samp", + "doc_type":"sdk-python-devg", + "kw":"Downloading an Object - Obtaining the Download Progress (SDK for Python),Object-Related APIs (SDK fo", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Downloading an Object - Obtaining the Download Progress (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0915.html", + "node_id":"obs_22_0915.xml", + "product_code":"obs", + "code":"62", + "des":"This API creates a folder in an existing bucket to manage data in OBS.OBS does not involve folders like in a file system. All elements stored in OBS buckets are objects. ", + "doc_type":"sdk-python-devg", + "kw":"Uploading an Object - Creating a Folder (SDK for Python),Object-Related APIs (SDK for Python),Python", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Uploading an Object - Creating a Folder (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0917.html", + "node_id":"obs_22_0917.xml", + "product_code":"obs", + "code":"63", + "des":"This API copies an object stored in OBS to another path, with a copy created during the process. You can create a copy of an object up to 5 GB in a single operation.To co", + "doc_type":"sdk-python-devg", + "kw":"Copying an Object (SDK for Python),Object-Related APIs (SDK for Python),Python SDK Developer Guide", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Copying an Object (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0918.html", + "node_id":"obs_22_0918.xml", + "product_code":"obs", + "code":"64", + "des":"This API deletes an object in the specified bucket to save space and costs.To delete an object, you must be the bucket owner or have the required permission (obs:object:D", + "doc_type":"sdk-python-devg", + "kw":"Deleting an Object (SDK for Python),Object-Related APIs (SDK for Python),Python SDK Developer Guide", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Deleting an Object (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0919.html", + "node_id":"obs_22_0919.xml", + "product_code":"obs", + "code":"65", + "des":"This API deletes objects in a batch from a specific bucket. Deleted objects cannot be restored.OBS does not involve folders like in a file system. All elements stored in ", + "doc_type":"sdk-python-devg", + "kw":"Batch Deleting Objects (SDK for Python),Object-Related APIs (SDK for Python),Python SDK Developer Gu", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Batch Deleting Objects (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0920.html", + "node_id":"obs_22_0920.xml", + "product_code":"obs", + "code":"66", + "des":"Object metadata is a set of name-value pairs that describe the object and is used for object management.Currently, only the system-defined metadata can be obtained. Syste", + "doc_type":"sdk-python-devg", + "kw":"Obtaining Object Metadata (SDK for Python),Object-Related APIs (SDK for Python),Python SDK Developer", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Obtaining Object Metadata (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0921.html", + "node_id":"obs_22_0921.xml", + "product_code":"obs", + "code":"67", + "des":"Object metadata is a set of name-value pairs that describe the object and is used for object management.Currently, only the system-defined metadata can be modified.System", + "doc_type":"sdk-python-devg", + "kw":"Modifying Object Metadata (SDK for Python),Object-Related APIs (SDK for Python),Python SDK Developer", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Modifying Object Metadata (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0922.html", + "node_id":"obs_22_0922.xml", + "product_code":"obs", + "code":"68", + "des":"OBS allows the control of access permissions for objects. By default, only object creators have the read and write permissions on the object. However, the creator can set", + "doc_type":"sdk-python-devg", + "kw":"Configuring an Object ACL (SDK for Python),Object-Related APIs (SDK for Python),Python SDK Developer", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Configuring an Object ACL (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0923.html", + "node_id":"obs_22_0923.xml", + "product_code":"obs", + "code":"69", + "des":"This API returns the ACL of an object in a specified bucket.To obtain an object ACL, you must be the bucket owner or have the required permission (obs:object:GetObjectAcl", + "doc_type":"sdk-python-devg", + "kw":"Obtaining an Object ACL (SDK for Python),Object-Related APIs (SDK for Python),Python SDK Developer G", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Obtaining an Object ACL (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_0924.html", + "node_id":"obs_22_0924.xml", + "product_code":"obs", + "code":"70", + "des":"To obtain the contents of an object in the Cold storage class, you need to restore the object first and then you can download it. After an object is restored, a copy of t", + "doc_type":"sdk-python-devg", + "kw":"Restoring a Cold Object (SDK for Python),Object-Related APIs (SDK for Python),Python SDK Developer G", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Restoring a Cold Object (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_1000.html", + "node_id":"obs_22_1000.xml", + "product_code":"obs", + "code":"71", + "des":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "doc_type":"sdk-python-devg", + "kw":"APIs Related to Multipart Upload (SDK for Python)", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"APIs Related to Multipart Upload (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_1001.html", + "node_id":"obs_22_1001.xml", + "product_code":"obs", + "code":"72", + "des":"You can upload large files using multipart upload. Multipart upload is applicable to many scenarios, including:Files to be uploaded are larger than 100 MB.The network con", + "doc_type":"sdk-python-devg", + "kw":"Multipart Upload Overview (SDK for Python),APIs Related to Multipart Upload (SDK for Python),Python ", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Multipart Upload Overview (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_1002.html", + "node_id":"obs_22_1002.xml", + "product_code":"obs", + "code":"73", + "des":"This API initiates a multipart upload and returns a globally unique upload ID. You can use the returned upload ID when you later upload, assemble, or list parts. A single", + "doc_type":"sdk-python-devg", + "kw":"Initiating a Multipart Upload (SDK for Python),APIs Related to Multipart Upload (SDK for Python),Pyt", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Initiating a Multipart Upload (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_1003.html", + "node_id":"obs_22_1003.xml", + "product_code":"obs", + "code":"74", + "des":"After a multipart upload is initiated, this API uploads a part to a specified bucket. In the upload request, the multipart upload ID must be included. Except for the part", + "doc_type":"sdk-python-devg", + "kw":"Uploading a Part (SDK for Python),APIs Related to Multipart Upload (SDK for Python),Python SDK Devel", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Uploading a Part (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_1004.html", + "node_id":"obs_22_1004.xml", + "product_code":"obs", + "code":"75", + "des":"This API lists the uploaded parts in a specified bucket. This request must contain the multipart upload ID.You can list the uploaded parts of a specified multipart upload", + "doc_type":"sdk-python-devg", + "kw":"Listing Uploaded Parts (SDK for Python),APIs Related to Multipart Upload (SDK for Python),Python SDK", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Listing Uploaded Parts (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_1005.html", + "node_id":"obs_22_1005.xml", + "product_code":"obs", + "code":"76", + "des":"This API lists ongoing multipart uploads.Ongoing multipart uploads are the multipart uploads that have been initiated but have not been completed or aborted. A maximum of", + "doc_type":"sdk-python-devg", + "kw":"Listing Multipart Uploads (SDK for Python),APIs Related to Multipart Upload (SDK for Python),Python ", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Listing Multipart Uploads (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_1006.html", + "node_id":"obs_22_1006.xml", + "product_code":"obs", + "code":"77", + "des":"This API assembles the uploaded parts to complete the multipart upload. Before performing this operation, you cannot download the uploaded data. When assembling parts, yo", + "doc_type":"sdk-python-devg", + "kw":"Assembling Parts (SDK for Python),APIs Related to Multipart Upload (SDK for Python),Python SDK Devel", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Assembling Parts (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_1007.html", + "node_id":"obs_22_1007.xml", + "product_code":"obs", + "code":"78", + "des":"This API copies a part to a specified bucket. This request must contain the multipart upload ID.After creating a multipart upload, you can specify the upload ID and uploa", + "doc_type":"sdk-python-devg", + "kw":"Copying a Part (SDK for Python),APIs Related to Multipart Upload (SDK for Python),Python SDK Develop", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Copying a Part (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_1008.html", + "node_id":"obs_22_1008.xml", + "product_code":"obs", + "code":"79", + "des":"This API aborts a multipart upload using the multipart upload ID.After a multipart upload is aborted, the upload ID cannot be used to upload any part. The storage occupie", + "doc_type":"sdk-python-devg", + "kw":"Aborting a Multipart Upload (SDK for Python),APIs Related to Multipart Upload (SDK for Python),Pytho", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Aborting a Multipart Upload (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_1009.html", + "node_id":"obs_22_1009.xml", + "product_code":"obs", + "code":"80", + "des":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "doc_type":"sdk-python-devg", + "kw":"Client-Side Encryption APIs (SDK for Python)", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Client-Side Encryption APIs (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_1010.html", + "node_id":"obs_22_1010.xml", + "product_code":"obs", + "code":"81", + "des":"Client-side encryption is a process where data is encrypted using the selected encryption method and information on your local PC before it is transmitted to an OBS serve", + "doc_type":"sdk-python-devg", + "kw":"Introduction (SDK for Python),Client-Side Encryption APIs (SDK for Python),Python SDK Developer Guid", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Introduction (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_1011.html", + "node_id":"obs_22_1011.xml", + "product_code":"obs", + "code":"82", + "des":"The OBS SDK for Python offers two types of CryptoCipher. Choose the one right for you.CtrRSACipherGenerator needs an RSA public or private key to encrypt the randomly gen", + "doc_type":"sdk-python-devg", + "kw":"Client-Side Encryption (SDK for Python),Client-Side Encryption APIs (SDK for Python),Python SDK Deve", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Client-Side Encryption (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_1300.html", + "node_id":"obs_22_1300.xml", + "product_code":"obs", + "code":"83", + "des":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "doc_type":"sdk-python-devg", + "kw":"Other APIs (SDK for Python)", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Other APIs (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_1301.html", + "node_id":"obs_22_1301.xml", + "product_code":"obs", + "code":"84", + "des":"This API creates a URL whose Query parameters are carried with authentication information by specifying the AK and SK, HTTP method, and request parameters. You can provid", + "doc_type":"sdk-python-devg", + "kw":"Creating a Signed URL (SDK for Python),Other APIs (SDK for Python),Python SDK Developer Guide", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Creating a Signed URL (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_1302.html", + "node_id":"obs_22_1302.xml", + "product_code":"obs", + "code":"85", + "des":"This API generates parameters for authentication. The parameters can be used to perform a browser-based upload through POST operations.There are two request parameters ge", + "doc_type":"sdk-python-devg", + "kw":"Generating Authentication Parameters for Browser-Based Uploads (SDK for Python),Other APIs (SDK for ", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Generating Authentication Parameters for Browser-Based Uploads (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_1303.html", + "node_id":"obs_22_1303.xml", + "product_code":"obs", + "code":"86", + "des":"This API configures server-side encryption for objects, so that they will be encrypted or decrypted when you upload them to or download them from a bucket.The encryption ", + "doc_type":"sdk-python-devg", + "kw":"Server-Side Encryption (SDK for Python),Other APIs (SDK for Python),Python SDK Developer Guide", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Server-Side Encryption (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_1304.html", + "node_id":"obs_22_1304.xml", + "product_code":"obs", + "code":"87", + "des":"This API uploads the files of the static website to your bucket in OBS as objects and configures the public-read permission on the files, and then configures the static w", + "doc_type":"sdk-python-devg", + "kw":"Static Website Hosting (SDK for Python),Other APIs (SDK for Python),Python SDK Developer Guide", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Static Website Hosting (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_1305.html", + "node_id":"obs_22_1305.xml", + "product_code":"obs", + "code":"88", + "des":"When calling an API, you can configure user-defined headers to meet specific needs. The SDK will automatically calculate the signature for the specified headers if needed", + "doc_type":"sdk-python-devg", + "kw":"User-defined Header (SDK for Python),Other APIs (SDK for Python),Python SDK Developer Guide", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"User-defined Header (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_1500.html", + "node_id":"obs_22_1500.xml", + "product_code":"obs", + "code":"89", + "des":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "doc_type":"sdk-python-devg", + "kw":"Troubleshooting (SDK for Python)", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Troubleshooting (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_1501.html", + "node_id":"obs_22_1501.xml", + "product_code":"obs", + "code":"90", + "des":"The OBS server complies with the HTTP standard. After an API is called, the OBS server returns a standard HTTP status code. The following tables list the categories of HT", + "doc_type":"sdk-python-devg", + "kw":"HTTP Status Codes (SDK for Python),Troubleshooting (SDK for Python),Python SDK Developer Guide", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"HTTP Status Codes (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_1502.html", + "node_id":"obs_22_1502.xml", + "product_code":"obs", + "code":"91", + "des":"If the OBS server encounters an error when processing a request, a response containing the error code and error description is returned.The following table lists details ", + "doc_type":"sdk-python-devg", + "kw":"OBS Server-Side Error Codes (SDK for Python),Troubleshooting (SDK for Python),Python SDK Developer G", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"OBS Server-Side Error Codes (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_1503.html", + "node_id":"obs_22_1503.xml", + "product_code":"obs", + "code":"92", + "des":"OBS Python SDK provides the logging function based on the Python log library. You can call ObsClient.initLog to enable and configure logging. Sample code is as follows:Th", + "doc_type":"sdk-python-devg", + "kw":"Log Analysis (SDK for Python),Troubleshooting (SDK for Python),Python SDK Developer Guide", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Log Analysis (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_1600.html", + "node_id":"obs_22_1600.xml", + "product_code":"obs", + "code":"93", + "des":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "doc_type":"sdk-python-devg", + "kw":"FAQs (SDK for Python)", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"FAQs (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_1607.html", + "node_id":"obs_22_1607.xml", + "product_code":"obs", + "code":"94", + "des":"To do this, perform the following steps:Set the object access permission to public-read by referring to Configuring an Object ACL (SDK for Python).Obtain the URL of the o", + "doc_type":"sdk-python-devg", + "kw":"How Do I Make an Object Accessible to Anonymous Users? (SDK for Python),FAQs (SDK for Python),Python", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"How Do I Make an Object Accessible to Anonymous Users? (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_1609.html", + "node_id":"obs_22_1609.xml", + "product_code":"obs", + "code":"95", + "des":"OBS employs access keys (AK and SK) for signature verification to ensure that only authorized accounts can access specified OBS resources. Detailed explanations of access", + "doc_type":"sdk-python-devg", + "kw":"How Can I Obtain the AK and SK? (SDK for Python),FAQs (SDK for Python),Python SDK Developer Guide", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"How Can I Obtain the AK and SK? (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_1613.html", + "node_id":"obs_22_1613.xml", + "product_code":"obs", + "code":"96", + "des":"After setting an ACL to grant anonymous users the read permission for an object in a bucket, you can download this object using its URL. Methods to obtain the object URL ", + "doc_type":"sdk-python-devg", + "kw":"How Do I Obtain an Object URL? (Python SDK),FAQs (SDK for Python),Python SDK Developer Guide", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"How Do I Obtain an Object URL? (Python SDK)", + "githuburl":"" + }, + { + "uri":"obs_22_1614.html", + "node_id":"obs_22_1614.xml", + "product_code":"obs", + "code":"97", + "des":"If a file exceeds 100 MB, you are advised to upload the file using multipart upload.Multipart upload refers to splitting an object into multiple parts and uploading them ", + "doc_type":"sdk-python-devg", + "kw":"How Do I Improve the Uploading Speed of Large Files over the Public Network? (SDK for Python),FAQs (", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"How Do I Improve the Uploading Speed of Large Files over the Public Network? (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_1704.html", + "node_id":"obs_22_1704.xml", + "product_code":"obs", + "code":"98", + "des":"This example sets the object expiration time using a header when uploading a file stream.This example sets the object expiration time using a user-defined header when upl", + "doc_type":"sdk-python-devg", + "kw":"Setting an Object Expiration Time (SDK for Python),FAQs (SDK for Python),Python SDK Developer Guide", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Setting an Object Expiration Time (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_1702.html", + "node_id":"obs_22_1702.xml", + "product_code":"obs", + "code":"99", + "des":"Multipurpose Internet Mail Extensions (MIME) type is a standard way of describing a data type. The MIME type is passed in the Content-Type header.If you do not specify Co", + "doc_type":"sdk-python-devg", + "kw":"What Is Content-Type (MIME)? (Python SDK),FAQs (SDK for Python),Python SDK Developer Guide", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"What Is Content-Type (MIME)? (Python SDK)", + "githuburl":"" + }, + { + "uri":"obs_22_1703.html", + "node_id":"obs_22_1703.xml", + "product_code":"obs", + "code":"100", + "des":"When calling APIs, you may need to specify the account ID (DomainID) and user ID (UserID) in some requests. You need to obtain them from the console in advance. To obtain", + "doc_type":"sdk-python-devg", + "kw":"How Do I Get My Account ID and IAM User ID? (SDK for Python),FAQs (SDK for Python),Python SDK Develo", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"How Do I Get My Account ID and IAM User ID? (SDK for Python)", + "githuburl":"" + }, + { + "uri":"obs_22_1701.html", + "node_id":"obs_22_1701.xml", + "product_code":"obs", + "code":"101", + "des":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "doc_type":"sdk-python-devg", + "kw":"Change History,Python SDK Developer Guide", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-python-devg" + } + ], + "title":"Change History", + "githuburl":"" + } +] \ No newline at end of file diff --git a/docs/obs_3rd_party/python_sdk/CLASS.TXT.json b/docs/obs_3rd_party/python_sdk/CLASS.TXT.json new file mode 100644 index 000000000..a778209ed --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/CLASS.TXT.json @@ -0,0 +1,911 @@ +[ + { + "desc":"This section describes the important notes about Object Storage Service (OBS) SDK for Python.Some features are available only in some regions. If 405 HTTP status code is ", + "product_code":"obs", + "title":"Before You Start (SDK for Python)", + "uri":"obs_22_0001.html", + "doc_type":"sdk-python-devg", + "p_code":"", + "code":"1" + }, + { + "desc":"Table 1 describes the APIs provided by OBS SDK for Python. You can click an API name in the table to see its detailed information and sample code.", + "product_code":"obs", + "title":"API Overview of OBS SDK for Python", + "uri":"obs_22_0100.html", + "doc_type":"sdk-python-devg", + "p_code":"", + "code":"2" + }, + { + "desc":"Before using OBS SDK for Python to access OBS, you need to prepare the service and development environments. To prepare the service environment, you must get an account a", + "product_code":"obs", + "title":"Preparations (SDK for Python)", + "uri":"obs_22_0300.html", + "doc_type":"sdk-python-devg", + "p_code":"", + "code":"3" + }, + { + "desc":"This topic provides the download links and installation methods of OBS SDK for Python.Latest version of OBS Python SDK source code: DownloadYou can use the methods listed", + "product_code":"obs", + "title":"Downloading and Installing OBS SDK for Python", + "uri":"obs_22_0400.html", + "doc_type":"sdk-python-devg", + "p_code":"", + "code":"4" + }, + { + "desc":"OBS employs access keys (AK and SK) for signature verification to ensure that only authorized accounts can access specified OBS resources. Detailed explanations of access", + "product_code":"obs", + "title":"Getting Started with OBS SDK for Python", + "uri":"obs_22_0500.html", + "doc_type":"sdk-python-devg", + "p_code":"", + "code":"5" + }, + { + "desc":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "product_code":"obs", + "title":"Initialization (SDK for Python)", + "uri":"obs_22_0600.html", + "doc_type":"sdk-python-devg", + "p_code":"", + "code":"6" + }, + { + "desc":"ObsClient functions as the Python client for accessing OBS. It offers users a series of APIs for interaction with OBS. These APIs are used for managing resources, such as", + "product_code":"obs", + "title":"Initializing an Instance of ObsClient (SDK for Python)", + "uri":"obs_22_0601.html", + "doc_type":"sdk-python-devg", + "p_code":"6", + "code":"7" + }, + { + "desc":"BucketClient functions as the Python client for accessing an OBS bucket. It offers users a series of APIs for interaction with OBS. These APIs are used for managing resou", + "product_code":"obs", + "title":"Initializing a BucketClient Instance (SDK for Python)", + "uri":"obs_22_0602.html", + "doc_type":"sdk-python-devg", + "p_code":"6", + "code":"8" + }, + { + "desc":"You can enable the SDK log function to record log information generated during API calling into log files for subsequent data analysis or fault location. The procedure is", + "product_code":"obs", + "title":"Log Initialization (SDK for Python)", + "uri":"obs_22_0603.html", + "doc_type":"sdk-python-devg", + "p_code":"6", + "code":"9" + }, + { + "desc":"Each time an ObsClient related API is called (excluding ObsClient.createSignedUrl and ObsClient.createPostSignature), an SDK common result object will be returned. You ca", + "product_code":"obs", + "title":"SDK Common Results (SDK for Python)", + "uri":"obs_22_0604.html", + "doc_type":"sdk-python-devg", + "p_code":"6", + "code":"10" + }, + { + "desc":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "product_code":"obs", + "title":"Bucket-Related APIs (SDK for Python)", + "uri":"obs_22_0800.html", + "doc_type":"sdk-python-devg", + "p_code":"", + "code":"11" + }, + { + "desc":"This API creates an OBS bucket. Buckets are containers for storing objects (files uploaded to OBS) in OBS.When creating a bucket, you can also configure parameters such a", + "product_code":"obs", + "title":"Creating a Bucket (SDK for Python)", + "uri":"obs_22_0801.html", + "doc_type":"sdk-python-devg", + "p_code":"11", + "code":"12" + }, + { + "desc":"OBS buckets are containers for storing objects you upload to OBS. This API returns a list of all buckets that meet the specified conditions in all regions of the current ", + "product_code":"obs", + "title":"Obtaining a Bucket List (SDK for Python)", + "uri":"obs_22_0802.html", + "doc_type":"sdk-python-devg", + "p_code":"11", + "code":"13" + }, + { + "desc":"This API checks whether a bucket exists. If an HTTP status code 200 is returned, the bucket exists. If 404 is returned, the bucket does not exist.To determine whether a b", + "product_code":"obs", + "title":"Checking Whether a Bucket Exists (SDK for Python)", + "uri":"obs_22_0803.html", + "doc_type":"sdk-python-devg", + "p_code":"11", + "code":"14" + }, + { + "desc":"This API deletes an empty bucket. You can delete buckets you no longer use to free up space. The name of a deleted bucket can be reused for another bucket at least 30 min", + "product_code":"obs", + "title":"Deleting a Bucket (SDK for Python)", + "uri":"obs_22_0804.html", + "doc_type":"sdk-python-devg", + "p_code":"11", + "code":"15" + }, + { + "desc":"This API lists some or all of the objects in a bucket. You can use parameters such as the prefix, number of returned objects, and start position to list objects that meet", + "product_code":"obs", + "title":"Listing Objects in a Bucket (SDK for Python)", + "uri":"obs_22_0805.html", + "doc_type":"sdk-python-devg", + "p_code":"11", + "code":"16" + }, + { + "desc":"This API lists some or all of the object versions in a bucket. You can use parameters such as the prefix, number of returned object versions, and start position to list t", + "product_code":"obs", + "title":"Listing Object Versions in a Bucket (SDK for Python)", + "uri":"obs_22_0806.html", + "doc_type":"sdk-python-devg", + "p_code":"11", + "code":"17" + }, + { + "desc":"This API returns information about a bucket, including the storage class, region, CORS rules, and redundancy policy.To obtain bucket metadata, you must be the bucket owne", + "product_code":"obs", + "title":"Obtaining Bucket Metadata (SDK for Python)", + "uri":"obs_22_0807.html", + "doc_type":"sdk-python-devg", + "p_code":"11", + "code":"18" + }, + { + "desc":"This API returns the region of a bucket.To obtain the region of a bucket, you must be the bucket owner or have the required permission (obs:bucket:GetBucketLocation in IA", + "product_code":"obs", + "title":"Obtaining the Region of a Bucket (SDK for Python)", + "uri":"obs_22_0808.html", + "doc_type":"sdk-python-devg", + "p_code":"11", + "code":"19" + }, + { + "desc":"This API returns the storage information of a bucket, including the number of objects and the space occupied by the objects in the bucket.OBS measures bucket storage stat", + "product_code":"obs", + "title":"Obtaining Storage Information of a Bucket (SDK for Python)", + "uri":"obs_22_0809.html", + "doc_type":"sdk-python-devg", + "p_code":"11", + "code":"20" + }, + { + "desc":"A quota limits the maximum capacity allowed in a bucket. By default, there is no limit on the storage capacity of the entire OBS system or a single bucket, and any number", + "product_code":"obs", + "title":"Configuring a Storage Quota (SDK for Python)", + "uri":"obs_22_0810.html", + "doc_type":"sdk-python-devg", + "p_code":"11", + "code":"21" + }, + { + "desc":"This API returns the storage quota (upper limit of the storage capacity) of a bucket. If the quota is 0, there is no upper limit on the bucket capacity.A bucket storage q", + "product_code":"obs", + "title":"Obtaining a Bucket Storage Quota (SDK for Python)", + "uri":"obs_22_0811.html", + "doc_type":"sdk-python-devg", + "p_code":"11", + "code":"22" + }, + { + "desc":"This API configures a storage class for a bucket. If you do not specify a storage class when uploading or copying an object, or initiating a multipart upload, the object ", + "product_code":"obs", + "title":"Configuring a Storage Class for a Bucket (SDK for Python)", + "uri":"obs_22_0812.html", + "doc_type":"sdk-python-devg", + "p_code":"11", + "code":"23" + }, + { + "desc":"This API returns the storage class of a bucket.To obtain a bucket's storage class, you must be the bucket owner or have the required permission (obs:bucket:GetBucketStora", + "product_code":"obs", + "title":"Obtaining the Storage Class of a Bucket (SDK for Python)", + "uri":"obs_22_0813.html", + "doc_type":"sdk-python-devg", + "p_code":"11", + "code":"24" + }, + { + "desc":"OBS provides access control over buckets. You can use an access policy to define whether a user can perform certain operations on a specific bucket. OBS access control ca", + "product_code":"obs", + "title":"Configuring a Bucket ACL (SDK for Python)", + "uri":"obs_22_0814.html", + "doc_type":"sdk-python-devg", + "p_code":"11", + "code":"25" + }, + { + "desc":"OBS provides access control over buckets. You can use an access policy to define whether a user can perform certain operations on a specific bucket. OBS access control ca", + "product_code":"obs", + "title":"Obtaining a Bucket ACL (SDK for Python)", + "uri":"obs_22_0815.html", + "doc_type":"sdk-python-devg", + "p_code":"11", + "code":"26" + }, + { + "desc":"This API enables logging for a bucket (source) and configures another bucket (target) to store the log files. When a bucket is created, logging is not enabled by default.", + "product_code":"obs", + "title":"Configuring Logging for a Bucket (SDK for Python)", + "uri":"obs_22_0816.html", + "doc_type":"sdk-python-devg", + "p_code":"11", + "code":"27" + }, + { + "desc":"This API returns the logging configuration of a bucket.To obtain the logging configuration of a bucket, you must be the bucket owner or have the required permission (obs:", + "product_code":"obs", + "title":"Obtaining the Logging Configuration of a Bucket (SDK for Python)", + "uri":"obs_22_0817.html", + "doc_type":"sdk-python-devg", + "p_code":"11", + "code":"28" + }, + { + "desc":"OBS provides access control over buckets. You can use an access policy to define whether a user can perform certain operations on a specific bucket. OBS access control ca", + "product_code":"obs", + "title":"Configuring a Bucket Policy (SDK for Python)", + "uri":"obs_22_0818.html", + "doc_type":"sdk-python-devg", + "p_code":"11", + "code":"29" + }, + { + "desc":"OBS provides access control over buckets. You can use an access policy to define whether a user can perform certain operations on a specific bucket. OBS access control ca", + "product_code":"obs", + "title":"Obtaining the Policy of a Bucket (SDK for Python)", + "uri":"obs_22_0819.html", + "doc_type":"sdk-python-devg", + "p_code":"11", + "code":"30" + }, + { + "desc":"OBS provides access control over buckets. You can use an access policy to define whether a user can perform certain operations on a specific bucket. OBS access control ca", + "product_code":"obs", + "title":"Deleting a Bucket Policy (SDK for Python)", + "uri":"obs_22_0820.html", + "doc_type":"sdk-python-devg", + "p_code":"11", + "code":"31" + }, + { + "desc":"You can configure lifecycle rules to periodically delete objects or transition objects between storage classes.This API configures lifecycle rules for a bucket.Expired ob", + "product_code":"obs", + "title":"Configuring Lifecycle Rules for a Bucket (SDK for Python)", + "uri":"obs_22_0821.html", + "doc_type":"sdk-python-devg", + "p_code":"11", + "code":"32" + }, + { + "desc":"You can configure lifecycle rules to periodically delete objects or transition objects between storage classes.This API returns the lifecycle rules of a bucket.To obtain ", + "product_code":"obs", + "title":"Obtaining the Lifecycle Configuration of a Bucket (SDK for Python)", + "uri":"obs_22_0822.html", + "doc_type":"sdk-python-devg", + "p_code":"11", + "code":"33" + }, + { + "desc":"You can configure lifecycle rules to periodically delete objects or transition objects between storage classes.This API deletes the lifecycle configuration of a bucket.To", + "product_code":"obs", + "title":"Deleting the Lifecycle Configuration of a Bucket (SDK for Python)", + "uri":"obs_22_0823.html", + "doc_type":"sdk-python-devg", + "p_code":"11", + "code":"34" + }, + { + "desc":"You can host static website resources such as HTML web pages, flash files, or audio and video files in an OBS bucket, so that you can provide these hosted resources using", + "product_code":"obs", + "title":"Configuring Static Website Hosting for a Bucket (SDK for Python)", + "uri":"obs_22_0824.html", + "doc_type":"sdk-python-devg", + "p_code":"11", + "code":"35" + }, + { + "desc":"You can host static website resources such as HTML web pages, flash files, as well as audio and video files in an OBS bucket, so that you can provide these hosted resourc", + "product_code":"obs", + "title":"Obtaining Static Website Hosting for a Bucket (SDK for Python)", + "uri":"obs_22_0825.html", + "doc_type":"sdk-python-devg", + "p_code":"11", + "code":"36" + }, + { + "desc":"You can host static website resources such as HTML web pages, flash files, as well as audio and video files in an OBS bucket, so that you can provide these hosted resourc", + "product_code":"obs", + "title":"Deleting Static Website Hosting for a Bucket (SDK for Python)", + "uri":"obs_22_0826.html", + "doc_type":"sdk-python-devg", + "p_code":"11", + "code":"37" + }, + { + "desc":"You can enable versioning to automatically maintain previous versions of an object. When versioning is enabled, you can access earlier versions of an object to recover yo", + "product_code":"obs", + "title":"Configuring Versioning for a Bucket (SDK for Python)", + "uri":"obs_22_0827.html", + "doc_type":"sdk-python-devg", + "p_code":"11", + "code":"38" + }, + { + "desc":"You can enable versioning to automatically maintain previous versions of an object. When versioning is enabled, you can access earlier versions of an object to recover yo", + "product_code":"obs", + "title":"Obtaining the Versioning Status of a Bucket (SDK for Python)", + "uri":"obs_22_0828.html", + "doc_type":"sdk-python-devg", + "p_code":"11", + "code":"39" + }, + { + "desc":"Cross-origin resource sharing (CORS) is a mechanism defined by the World Wide Web Consortium (W3C) that allows a web application program in one domain to access resources", + "product_code":"obs", + "title":"Configuring CORS for a Bucket (SDK for Python)", + "uri":"obs_22_0829.html", + "doc_type":"sdk-python-devg", + "p_code":"11", + "code":"40" + }, + { + "desc":"Cross-origin resource sharing (CORS) is a mechanism defined by the World Wide Web Consortium (W3C) that allows a web application program in one domain to access resources", + "product_code":"obs", + "title":"Obtaining the CORS Configuration of a Bucket (SDK for Python)", + "uri":"obs_22_0830.html", + "doc_type":"sdk-python-devg", + "p_code":"11", + "code":"41" + }, + { + "desc":"Cross-origin resource sharing (CORS) is a mechanism defined by the World Wide Web Consortium (W3C) that allows a web application program in one domain to access resources", + "product_code":"obs", + "title":"Deleting the CORS Configuration of a Bucket (SDK for Python)", + "uri":"obs_22_0831.html", + "doc_type":"sdk-python-devg", + "p_code":"11", + "code":"42" + }, + { + "desc":"If you add tags to a bucket, SDRs generated for the requests sent to this bucket will include these tags, so you can use the tags to classify SDRs for detailed cost analy", + "product_code":"obs", + "title":"Configuring Tags for a Bucket (SDK for Python)", + "uri":"obs_22_0834.html", + "doc_type":"sdk-python-devg", + "p_code":"11", + "code":"43" + }, + { + "desc":"If you add tags to a bucket, SDRs generated for the requests sent to this bucket will include these tags, so you can use the tags to classify SDRs for detailed cost analy", + "product_code":"obs", + "title":"Obtaining Bucket Tags (SDK for Python)", + "uri":"obs_22_0835.html", + "doc_type":"sdk-python-devg", + "p_code":"11", + "code":"44" + }, + { + "desc":"If you add tags to a bucket, SDRs generated for the requests sent to this bucket will include these tags, so you can use the tags to classify SDRs for detailed cost analy", + "product_code":"obs", + "title":"Deleting Bucket Tags (SDK for Python)", + "uri":"obs_22_0836.html", + "doc_type":"sdk-python-devg", + "p_code":"11", + "code":"45" + }, + { + "desc":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "product_code":"obs", + "title":"Object-Related APIs (SDK for Python)", + "uri":"obs_22_0900.html", + "doc_type":"sdk-python-devg", + "p_code":"", + "code":"46" + }, + { + "desc":"You can use this API to upload an object to a specified bucket. In OBS, objects are basic data units that you can operate. OBS Python SDK provides many APIs for uploading", + "product_code":"obs", + "title":"Object Upload Overview (SDK for Python)", + "uri":"obs_22_0501.html", + "doc_type":"sdk-python-devg", + "p_code":"46", + "code":"47" + }, + { + "desc":"This API uploads the text using strings as the data source to a specified bucket.To upload an object, you must be the bucket owner or have the required permission (obs:ob", + "product_code":"obs", + "title":"Uploading Objects - Text-Based (SDK for Python)", + "uri":"obs_22_0901.html", + "doc_type":"sdk-python-devg", + "p_code":"46", + "code":"48" + }, + { + "desc":"You can upload texts, images, videos, or any other types of files smaller than 5 GB.Streaming upload uses readable objects that contain the read attribute as the data sou", + "product_code":"obs", + "title":"Uploading an Object - Streaming (SDK for Python)", + "uri":"obs_22_0902.html", + "doc_type":"sdk-python-devg", + "p_code":"46", + "code":"49" + }, + { + "desc":"This API uploads local filesto OBS over the Internet. These files can be texts, images, videos, or any other type of files.OBS does not involve folders like in a file sys", + "product_code":"obs", + "title":"Uploading an Object - File-Based (SDK for Python)", + "uri":"obs_22_0903.html", + "doc_type":"sdk-python-devg", + "p_code":"46", + "code":"50" + }, + { + "desc":"This API uploads a file or folder to an existing OBS bucket. These files can be texts, images, videos, or any other type of files.The AppendObject operation adds data to ", + "product_code":"obs", + "title":"Uploading an Object - Append (SDK for Python)", + "uri":"obs_22_0904.html", + "doc_type":"sdk-python-devg", + "p_code":"46", + "code":"51" + }, + { + "desc":"The resumable upload is an encapsulated and enhanced version of the multipart upload used for dealing with possible upload failures of large files when the network connec", + "product_code":"obs", + "title":"Uploading an Object - Resumable (SDK for Python)", + "uri":"obs_22_0905.html", + "doc_type":"sdk-python-devg", + "p_code":"46", + "code":"52" + }, + { + "desc":"You can query the upload progress when uploading an object in streaming, file-based, multipart, appendable, or resumable mode.This example configures a callback function ", + "product_code":"obs", + "title":"Obtaining the Upload Progress (SDK for Python)", + "uri":"obs_22_0906.html", + "doc_type":"sdk-python-devg", + "p_code":"46", + "code":"53" + }, + { + "desc":"This API uploads an object up to 5 GB to a specified bucket in HTML form. You can call ObsClient.createPostSignature to generate parameters for requesting a browser-based", + "product_code":"obs", + "title":"Uploading an Object - Browser-Based (SDK for Python)", + "uri":"obs_22_0907.html", + "doc_type":"sdk-python-devg", + "p_code":"46", + "code":"54" + }, + { + "desc":"OBS Python SDK provides abundant APIs for downloading objects using various methods:Binary DownloadStreaming DownloadFile-Based DownloadPartial DownloadResumable Download", + "product_code":"obs", + "title":"Object Download Overview (SDK for Python)", + "uri":"obs_22_0502.html", + "doc_type":"sdk-python-devg", + "p_code":"46", + "code":"55" + }, + { + "desc":"This API downloads an object in binary from OBS to your local computer.To download an object, you must be the bucket owner or have the required permission (obs:object:Get", + "product_code":"obs", + "title":"Downloading an Object - Binary (SDK for Python)", + "uri":"obs_22_0908.html", + "doc_type":"sdk-python-devg", + "p_code":"46", + "code":"56" + }, + { + "desc":"This API downloads an object using streaming from OBS to your local computer.To download an object, you must be the bucket owner or have the required permission (obs:obje", + "product_code":"obs", + "title":"Downloading an Object - Streaming (SDK for Python)", + "uri":"obs_22_0909.html", + "doc_type":"sdk-python-devg", + "p_code":"46", + "code":"57" + }, + { + "desc":"This API downloads an object as a file from OBS to your local computer.To download an object, you must be the bucket owner or have the required permission (obs:object:Get", + "product_code":"obs", + "title":"Downloading an Object - File-Based (SDK for Python)", + "uri":"obs_22_0910.html", + "doc_type":"sdk-python-devg", + "p_code":"46", + "code":"58" + }, + { + "desc":"This API downloads partial data of an object by specifying a range. If the specified range is from 0 to 1,000, data from byte 0 to byte 1,000, 1,001 bytes in total, are r", + "product_code":"obs", + "title":"Downloading an Object - Range-Based (SDK for Python)", + "uri":"obs_22_0911.html", + "doc_type":"sdk-python-devg", + "p_code":"46", + "code":"59" + }, + { + "desc":"Downloading large files often fails due to unstable network or program breakdown. It is a waste of resources to download files again. Moreover, the restarted download may", + "product_code":"obs", + "title":"Downloading an Object - Resumable (SDK for Python)", + "uri":"obs_22_0912.html", + "doc_type":"sdk-python-devg", + "p_code":"46", + "code":"60" + }, + { + "desc":"You can obtain the download progress when downloading an object in binary, streaming, file-based, or resumable mode.This example returns the object download progress.Samp", + "product_code":"obs", + "title":"Downloading an Object - Obtaining the Download Progress (SDK for Python)", + "uri":"obs_22_0913.html", + "doc_type":"sdk-python-devg", + "p_code":"46", + "code":"61" + }, + { + "desc":"This API creates a folder in an existing bucket to manage data in OBS.OBS does not involve folders like in a file system. All elements stored in OBS buckets are objects. ", + "product_code":"obs", + "title":"Uploading an Object - Creating a Folder (SDK for Python)", + "uri":"obs_22_0915.html", + "doc_type":"sdk-python-devg", + "p_code":"46", + "code":"62" + }, + { + "desc":"This API copies an object stored in OBS to another path, with a copy created during the process. You can create a copy of an object up to 5 GB in a single operation.To co", + "product_code":"obs", + "title":"Copying an Object (SDK for Python)", + "uri":"obs_22_0917.html", + "doc_type":"sdk-python-devg", + "p_code":"46", + "code":"63" + }, + { + "desc":"This API deletes an object in the specified bucket to save space and costs.To delete an object, you must be the bucket owner or have the required permission (obs:object:D", + "product_code":"obs", + "title":"Deleting an Object (SDK for Python)", + "uri":"obs_22_0918.html", + "doc_type":"sdk-python-devg", + "p_code":"46", + "code":"64" + }, + { + "desc":"This API deletes objects in a batch from a specific bucket. Deleted objects cannot be restored.OBS does not involve folders like in a file system. All elements stored in ", + "product_code":"obs", + "title":"Batch Deleting Objects (SDK for Python)", + "uri":"obs_22_0919.html", + "doc_type":"sdk-python-devg", + "p_code":"46", + "code":"65" + }, + { + "desc":"Object metadata is a set of name-value pairs that describe the object and is used for object management.Currently, only the system-defined metadata can be obtained. Syste", + "product_code":"obs", + "title":"Obtaining Object Metadata (SDK for Python)", + "uri":"obs_22_0920.html", + "doc_type":"sdk-python-devg", + "p_code":"46", + "code":"66" + }, + { + "desc":"Object metadata is a set of name-value pairs that describe the object and is used for object management.Currently, only the system-defined metadata can be modified.System", + "product_code":"obs", + "title":"Modifying Object Metadata (SDK for Python)", + "uri":"obs_22_0921.html", + "doc_type":"sdk-python-devg", + "p_code":"46", + "code":"67" + }, + { + "desc":"OBS allows the control of access permissions for objects. By default, only object creators have the read and write permissions on the object. However, the creator can set", + "product_code":"obs", + "title":"Configuring an Object ACL (SDK for Python)", + "uri":"obs_22_0922.html", + "doc_type":"sdk-python-devg", + "p_code":"46", + "code":"68" + }, + { + "desc":"This API returns the ACL of an object in a specified bucket.To obtain an object ACL, you must be the bucket owner or have the required permission (obs:object:GetObjectAcl", + "product_code":"obs", + "title":"Obtaining an Object ACL (SDK for Python)", + "uri":"obs_22_0923.html", + "doc_type":"sdk-python-devg", + "p_code":"46", + "code":"69" + }, + { + "desc":"To obtain the contents of an object in the Cold storage class, you need to restore the object first and then you can download it. After an object is restored, a copy of t", + "product_code":"obs", + "title":"Restoring a Cold Object (SDK for Python)", + "uri":"obs_22_0924.html", + "doc_type":"sdk-python-devg", + "p_code":"46", + "code":"70" + }, + { + "desc":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "product_code":"obs", + "title":"APIs Related to Multipart Upload (SDK for Python)", + "uri":"obs_22_1000.html", + "doc_type":"sdk-python-devg", + "p_code":"", + "code":"71" + }, + { + "desc":"You can upload large files using multipart upload. Multipart upload is applicable to many scenarios, including:Files to be uploaded are larger than 100 MB.The network con", + "product_code":"obs", + "title":"Multipart Upload Overview (SDK for Python)", + "uri":"obs_22_1001.html", + "doc_type":"sdk-python-devg", + "p_code":"71", + "code":"72" + }, + { + "desc":"This API initiates a multipart upload and returns a globally unique upload ID. You can use the returned upload ID when you later upload, assemble, or list parts. A single", + "product_code":"obs", + "title":"Initiating a Multipart Upload (SDK for Python)", + "uri":"obs_22_1002.html", + "doc_type":"sdk-python-devg", + "p_code":"71", + "code":"73" + }, + { + "desc":"After a multipart upload is initiated, this API uploads a part to a specified bucket. In the upload request, the multipart upload ID must be included. Except for the part", + "product_code":"obs", + "title":"Uploading a Part (SDK for Python)", + "uri":"obs_22_1003.html", + "doc_type":"sdk-python-devg", + "p_code":"71", + "code":"74" + }, + { + "desc":"This API lists the uploaded parts in a specified bucket. This request must contain the multipart upload ID.You can list the uploaded parts of a specified multipart upload", + "product_code":"obs", + "title":"Listing Uploaded Parts (SDK for Python)", + "uri":"obs_22_1004.html", + "doc_type":"sdk-python-devg", + "p_code":"71", + "code":"75" + }, + { + "desc":"This API lists ongoing multipart uploads.Ongoing multipart uploads are the multipart uploads that have been initiated but have not been completed or aborted. A maximum of", + "product_code":"obs", + "title":"Listing Multipart Uploads (SDK for Python)", + "uri":"obs_22_1005.html", + "doc_type":"sdk-python-devg", + "p_code":"71", + "code":"76" + }, + { + "desc":"This API assembles the uploaded parts to complete the multipart upload. Before performing this operation, you cannot download the uploaded data. When assembling parts, yo", + "product_code":"obs", + "title":"Assembling Parts (SDK for Python)", + "uri":"obs_22_1006.html", + "doc_type":"sdk-python-devg", + "p_code":"71", + "code":"77" + }, + { + "desc":"This API copies a part to a specified bucket. This request must contain the multipart upload ID.After creating a multipart upload, you can specify the upload ID and uploa", + "product_code":"obs", + "title":"Copying a Part (SDK for Python)", + "uri":"obs_22_1007.html", + "doc_type":"sdk-python-devg", + "p_code":"71", + "code":"78" + }, + { + "desc":"This API aborts a multipart upload using the multipart upload ID.After a multipart upload is aborted, the upload ID cannot be used to upload any part. The storage occupie", + "product_code":"obs", + "title":"Aborting a Multipart Upload (SDK for Python)", + "uri":"obs_22_1008.html", + "doc_type":"sdk-python-devg", + "p_code":"71", + "code":"79" + }, + { + "desc":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "product_code":"obs", + "title":"Client-Side Encryption APIs (SDK for Python)", + "uri":"obs_22_1009.html", + "doc_type":"sdk-python-devg", + "p_code":"", + "code":"80" + }, + { + "desc":"Client-side encryption is a process where data is encrypted using the selected encryption method and information on your local PC before it is transmitted to an OBS serve", + "product_code":"obs", + "title":"Introduction (SDK for Python)", + "uri":"obs_22_1010.html", + "doc_type":"sdk-python-devg", + "p_code":"80", + "code":"81" + }, + { + "desc":"The OBS SDK for Python offers two types of CryptoCipher. Choose the one right for you.CtrRSACipherGenerator needs an RSA public or private key to encrypt the randomly gen", + "product_code":"obs", + "title":"Client-Side Encryption (SDK for Python)", + "uri":"obs_22_1011.html", + "doc_type":"sdk-python-devg", + "p_code":"80", + "code":"82" + }, + { + "desc":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "product_code":"obs", + "title":"Other APIs (SDK for Python)", + "uri":"obs_22_1300.html", + "doc_type":"sdk-python-devg", + "p_code":"", + "code":"83" + }, + { + "desc":"This API creates a URL whose Query parameters are carried with authentication information by specifying the AK and SK, HTTP method, and request parameters. You can provid", + "product_code":"obs", + "title":"Creating a Signed URL (SDK for Python)", + "uri":"obs_22_1301.html", + "doc_type":"sdk-python-devg", + "p_code":"83", + "code":"84" + }, + { + "desc":"This API generates parameters for authentication. The parameters can be used to perform a browser-based upload through POST operations.There are two request parameters ge", + "product_code":"obs", + "title":"Generating Authentication Parameters for Browser-Based Uploads (SDK for Python)", + "uri":"obs_22_1302.html", + "doc_type":"sdk-python-devg", + "p_code":"83", + "code":"85" + }, + { + "desc":"This API configures server-side encryption for objects, so that they will be encrypted or decrypted when you upload them to or download them from a bucket.The encryption ", + "product_code":"obs", + "title":"Server-Side Encryption (SDK for Python)", + "uri":"obs_22_1303.html", + "doc_type":"sdk-python-devg", + "p_code":"83", + "code":"86" + }, + { + "desc":"This API uploads the files of the static website to your bucket in OBS as objects and configures the public-read permission on the files, and then configures the static w", + "product_code":"obs", + "title":"Static Website Hosting (SDK for Python)", + "uri":"obs_22_1304.html", + "doc_type":"sdk-python-devg", + "p_code":"83", + "code":"87" + }, + { + "desc":"When calling an API, you can configure user-defined headers to meet specific needs. The SDK will automatically calculate the signature for the specified headers if needed", + "product_code":"obs", + "title":"User-defined Header (SDK for Python)", + "uri":"obs_22_1305.html", + "doc_type":"sdk-python-devg", + "p_code":"83", + "code":"88" + }, + { + "desc":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "product_code":"obs", + "title":"Troubleshooting (SDK for Python)", + "uri":"obs_22_1500.html", + "doc_type":"sdk-python-devg", + "p_code":"", + "code":"89" + }, + { + "desc":"The OBS server complies with the HTTP standard. After an API is called, the OBS server returns a standard HTTP status code. The following tables list the categories of HT", + "product_code":"obs", + "title":"HTTP Status Codes (SDK for Python)", + "uri":"obs_22_1501.html", + "doc_type":"sdk-python-devg", + "p_code":"89", + "code":"90" + }, + { + "desc":"If the OBS server encounters an error when processing a request, a response containing the error code and error description is returned.The following table lists details ", + "product_code":"obs", + "title":"OBS Server-Side Error Codes (SDK for Python)", + "uri":"obs_22_1502.html", + "doc_type":"sdk-python-devg", + "p_code":"89", + "code":"91" + }, + { + "desc":"OBS Python SDK provides the logging function based on the Python log library. You can call ObsClient.initLog to enable and configure logging. Sample code is as follows:Th", + "product_code":"obs", + "title":"Log Analysis (SDK for Python)", + "uri":"obs_22_1503.html", + "doc_type":"sdk-python-devg", + "p_code":"89", + "code":"92" + }, + { + "desc":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "product_code":"obs", + "title":"FAQs (SDK for Python)", + "uri":"obs_22_1600.html", + "doc_type":"sdk-python-devg", + "p_code":"", + "code":"93" + }, + { + "desc":"To do this, perform the following steps:Set the object access permission to public-read by referring to Configuring an Object ACL (SDK for Python).Obtain the URL of the o", + "product_code":"obs", + "title":"How Do I Make an Object Accessible to Anonymous Users? (SDK for Python)", + "uri":"obs_22_1607.html", + "doc_type":"sdk-python-devg", + "p_code":"93", + "code":"94" + }, + { + "desc":"OBS employs access keys (AK and SK) for signature verification to ensure that only authorized accounts can access specified OBS resources. Detailed explanations of access", + "product_code":"obs", + "title":"How Can I Obtain the AK and SK? (SDK for Python)", + "uri":"obs_22_1609.html", + "doc_type":"sdk-python-devg", + "p_code":"93", + "code":"95" + }, + { + "desc":"After setting an ACL to grant anonymous users the read permission for an object in a bucket, you can download this object using its URL. Methods to obtain the object URL ", + "product_code":"obs", + "title":"How Do I Obtain an Object URL? (Python SDK)", + "uri":"obs_22_1613.html", + "doc_type":"sdk-python-devg", + "p_code":"93", + "code":"96" + }, + { + "desc":"If a file exceeds 100 MB, you are advised to upload the file using multipart upload.Multipart upload refers to splitting an object into multiple parts and uploading them ", + "product_code":"obs", + "title":"How Do I Improve the Uploading Speed of Large Files over the Public Network? (SDK for Python)", + "uri":"obs_22_1614.html", + "doc_type":"sdk-python-devg", + "p_code":"93", + "code":"97" + }, + { + "desc":"This example sets the object expiration time using a header when uploading a file stream.This example sets the object expiration time using a user-defined header when upl", + "product_code":"obs", + "title":"Setting an Object Expiration Time (SDK for Python)", + "uri":"obs_22_1704.html", + "doc_type":"sdk-python-devg", + "p_code":"93", + "code":"98" + }, + { + "desc":"Multipurpose Internet Mail Extensions (MIME) type is a standard way of describing a data type. The MIME type is passed in the Content-Type header.If you do not specify Co", + "product_code":"obs", + "title":"What Is Content-Type (MIME)? (Python SDK)", + "uri":"obs_22_1702.html", + "doc_type":"sdk-python-devg", + "p_code":"93", + "code":"99" + }, + { + "desc":"When calling APIs, you may need to specify the account ID (DomainID) and user ID (UserID) in some requests. You need to obtain them from the console in advance. To obtain", + "product_code":"obs", + "title":"How Do I Get My Account ID and IAM User ID? (SDK for Python)", + "uri":"obs_22_1703.html", + "doc_type":"sdk-python-devg", + "p_code":"93", + "code":"100" + }, + { + "desc":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "product_code":"obs", + "title":"Change History", + "uri":"obs_22_1701.html", + "doc_type":"sdk-python-devg", + "p_code":"", + "code":"101" + } +] \ No newline at end of file diff --git a/docs/obs_3rd_party/python_sdk/PARAMETERS.txt b/docs/obs_3rd_party/python_sdk/PARAMETERS.txt new file mode 100644 index 000000000..6da8d5f07 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/PARAMETERS.txt @@ -0,0 +1,3 @@ +version="" +language="en-us" +type="" \ No newline at end of file diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0001.html b/docs/obs_3rd_party/python_sdk/obs_22_0001.html new file mode 100644 index 000000000..90fd6ce0f --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0001.html @@ -0,0 +1,8 @@ + + +

Before You Start (SDK for Python)

+

This section describes the important notes about Object Storage Service (OBS) SDK for Python.

+

Important Notes

+
+
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0100.html b/docs/obs_3rd_party/python_sdk/obs_22_0100.html new file mode 100644 index 000000000..d0afb6a47 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0100.html @@ -0,0 +1,419 @@ + + +

API Overview of OBS SDK for Python

+

Table 1 describes the APIs provided by OBS SDK for Python. You can click an API name in the table to see its detailed information and sample code.

+

SDK API Overview

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 APIs provided by OBS SDK for Python

Interface

+

Method

+

Function

+

Creating a Bucket (SDK for Python)

+

ObsClient.createBucket

+

Creates a bucket.

+

Obtaining a Bucket List (SDK for Python)

+

ObsClient.listBuckets

+

Returns a list of buckets in alphabetical order.

+

Checking Whether a Bucket Exists (SDK for Python)

+

ObsClient.headBucket

+

Determines whether a bucket exists.

+

Deleting a Bucket (SDK for Python)

+

ObsClient.deleteBucket

+

Deletes an empty bucket.

+

Listing Objects in a Bucket (SDK for Python)

+

ObsClient.listObjects

+

Returns some or all (up to 1,000) of the objects in a bucket.

+

Listing Object Versions in a Bucket (SDK for Python)

+

ObsClient.listVersions

+

Lists some or all (up to 1,000) of the object versions in a bucket.

+

Listing Multipart Uploads (SDK for Python)

+

ObsClient.listMultipartUploads

+

Lists ongoing multipart uploads.

+

Obtaining Bucket Metadata (SDK for Python)

+

ObsClient.getBucketMetadata

+

Sends a HEAD request to a bucket to obtain the bucket metadata such as CORS rules (if set), the storage class, and other information.

+

Obtaining the Region of a Bucket (SDK for Python)

+

ObsClient.getBucketLocation

+

Returns the region where the bucket is created.

+

Obtaining Storage Information of a Bucket (SDK for Python)

+

ObsClient.getBucketStorageInfo

+

Returns the storage information of a bucket, including the number of objects and the space occupied by the objects in the bucket.

+

Configuring a Storage Quota (SDK for Python)

+

ObsClient.setBucketQuota

+

Sets a storage quota for a bucket.

+

Obtaining a Bucket Storage Quota (SDK for Python)

+

ObsClient.getBucketQuota

+

Returns the storage quota of a bucket.

+

Configuring a Storage Class for a Bucket (SDK for Python)

+

ObsClient.setBucketStoragePolicy

+

Configures a storage class for a bucket.

+

Obtaining the Storage Class of a Bucket (SDK for Python)

+

ObsClient.getBucketStoragePolicy

+

Returns the storage class of a bucket.

+

Configuring a Bucket ACL (SDK for Python)

+

ObsClient.setBucketAcl

+

Configures the ACL for a bucket.

+

Obtaining a Bucket ACL (SDK for Python)

+

ObsClient.getBucketAcl

+

Returns the bucket ACL.

+

Configuring Logging for a Bucket (SDK for Python)

+

ObsClient.setBucketLogging

+

Configures logging for a bucket.

+

Obtaining the Logging Configuration of a Bucket (SDK for Python)

+

ObsClient.getBucketLogging

+

Returns the logging configuration of a bucket.

+

Configuring a Bucket Policy (SDK for Python)

+

ObsClient.setBucketPolicy

+

Configures a bucket policy. If the bucket already has a policy, the policy will be overwritten by the one specified in this request.

+

Obtaining the Policy of a Bucket (SDK for Python)

+

ObsClient.getBucketPolicy

+

Returns the policy of a bucket.

+

Deleting a Bucket Policy (SDK for Python)

+

ObsClient.deleteBucketPolicy

+

Deletes the policy of a bucket.

+

Configuring Lifecycle Rules for a Bucket (SDK for Python)

+

ObsClient.setBucketLifecycle

+

Configures lifecycle rules for a bucket to periodically transition objects between storage classes or delete objects.

+

Obtaining the Lifecycle Configuration of a Bucket (SDK for Python)

+

ObsClient.getBucketLifecycle

+

Returns the lifecycle configuration of a bucket.

+

Deleting the Lifecycle Configuration of a Bucket (SDK for Python)

+

ObsClient.deleteBucketLifecycle

+

Deletes all lifecycle rules of a bucket.

+

Configuring Static Website Hosting for a Bucket (SDK for Python)

+

ObsClient.setBucketWebsite

+

Configures static website hosting for a bucket.

+

Obtaining Static Website Hosting for a Bucket (SDK for Python)

+

ObsClient.getBucketWebsite

+

Returns the static website hosting configuration of a bucket.

+

Deleting Static Website Hosting for a Bucket (SDK for Python)

+

ObsClient.deleteBucketWebsite

+

Deletes the static website hosting configurations of a bucket.

+

Configuring Versioning for a Bucket (SDK for Python)

+

ObsClient.setBucketVersioning

+

Configures versioning for a bucket.

+

Obtaining the Versioning Status of a Bucket (SDK for Python)

+

ObsClient.getBucketVersioning

+

Returns the versioning status of a bucket.

+

Configuring CORS for a Bucket (SDK for Python)

+

ObsClient.setBucketCors

+

Configures CORS for a bucket to allow cross-origin requests.

+

Obtaining the CORS Configuration of a Bucket (SDK for Python)

+

ObsClient.getBucketCors

+

Returns the CORS rules of a bucket.

+

Deleting the CORS Configuration of a Bucket (SDK for Python)

+

ObsClient.deleteBucketCors

+

Deletes the CORS configuration of a bucket.

+

Configuring Tags for a Bucket (SDK for Python)

+

ObsClient.setBucketTagging

+

Configures tags for a bucket.

+

Obtaining Bucket Tags (SDK for Python)

+

ObsClient.getBucketTagging

+

Returns the tags of a bucket.

+

Deleting Bucket Tags (SDK for Python)

+

ObsClient.deleteBucketTagging

+

Deletes the tags of a bucket.

+

Object Upload Overview (SDK for Python)

+

ObsClient.putContent

+

Uploads an object to a bucket.

+

Uploading an Object - File-Based (SDK for Python)

+

ObsClient.putFile

+

Uploads a file or folder to a bucket.

+

Uploading an Object - Append (SDK for Python)

+

ObsClient.appendObject

+

Appends content to an uploaded object.

+

Object Download Overview (SDK for Python)

+

ObsClient.getObject

+

Downloads an object from a bucket.

+

Copying an Object (SDK for Python)

+

ObsClient.copyObject

+

Creates a copy for a specified object.

+

Deleting an Object (SDK for Python)

+

ObsClient.deleteObject

+

Deletes a single object from a bucket.

+

Batch Deleting Objects (SDK for Python)

+

ObsClient.deleteObjects

+

Deletes multiple objects from a bucket in a batch.

+

Obtaining Object Metadata (SDK for Python)

+

ObsClient.getObjectMetadata

+

Returns the object metadata.

+

Modifying Object Metadata (SDK for Python)

+

ObsClient.setObjectMetadata

+

Modifies the metadata for an object.

+

Configuring an Object ACL (SDK for Python)

+

ObsClient.setObjectAcl

+

Configures the ACL for an object.

+

Obtaining an Object ACL (SDK for Python)

+

ObsClient.getObjectAcl

+

Returns the ACL of an object.

+

Initiating a Multipart Upload (SDK for Python)

+

ObsClient.initiateMultipartUpload

+

Initiates a multipart upload in a bucket.

+

Uploading a Part (SDK for Python)

+

ObsClient.uploadPart

+

Uploads parts to a bucket by specifying the multipart upload ID.

+

Copying a Part (SDK for Python)

+

ObsClient.copyPart

+

Copies a part to a specified bucket by specifying the multipart upload ID.

+

Listing Uploaded Parts (SDK for Python)

+

ObsClient.listParts

+

Returns the uploaded parts in a bucket by specifying the multipart upload ID.

+

Assembling Parts (SDK for Python)

+

ObsClient.completeMultipartUpload

+

Completes a multipart upload based on the multipart upload ID.

+

Aborting a Multipart Upload (SDK for Python)

+

ObsClient.abortMultipartUpload

+

Aborts a multipart upload in a bucket by specifying the multipart upload ID.

+

Restoring a Cold Object

+

ObsClient.restoreObject

+

Restores a Cold object.

+

Creating a Signed URL (SDK for Python)

+

ObsClient.createSignedUrl

+

Creates a signed URL based on the specified AK and SK, HTTP method, and request parameters.

+

Generating Authentication Parameters for Browser-Based Uploads (SDK for Python)

+

ObsClient.createPostSignature

+

Creates request parameters for authentication to enable browser-based upload with POST.

+

Uploading an Object - Resumable (SDK for Python)

+

ObsClient.uploadFile

+

Enables resumable uploads of objects in the event of unstable network connections or program crashes.

+

Downloading an Object - Resumable (SDK for Python)

+

ObsClient.downloadFile

+

Adds the resumable function to the partial download API.

+
+
+
+
+
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0300.html b/docs/obs_3rd_party/python_sdk/obs_22_0300.html new file mode 100644 index 000000000..fd5db814c --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0300.html @@ -0,0 +1,22 @@ + + +

Preparations (SDK for Python)

+

Before using OBS SDK for Python to access OBS, you need to prepare the service and development environments. To prepare the service environment, you must get an account and an access key. Both of them are necessary for interaction between OBS SDK for Python and OBS. To ensure successful SDK installation and SDK-based code development and running, you should also set up a local development environment, for example, installing dependencies and development tools.

+

Preparing Access Keys

Access keys consist of two parts: an access key ID (AK) and a secret access key (SK). OBS uses access keys to sign requests to make sure that only authorized accounts can access specified OBS resources. Programmatic access must be enabled for an IAM user before the IAM user can get access keys. Access keys are explained as follows:

+ +

Access keys are classified into permanent access keys (AK/SK) and temporary access keys (AK/SK and security token). Each user can create at most two permanent access keys. Temporary access keys must be used within a given validity period. Once expired, they must be requested again. For security purposes, you are advised to use temporary access keys to access OBS. If you want to use permanent access keys, periodically update them. The following describes how to obtain two types of access keys.

+ +
+

Setting Up a Development Environment

+
+
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0400.html b/docs/obs_3rd_party/python_sdk/obs_22_0400.html new file mode 100644 index 000000000..dffbc5a95 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0400.html @@ -0,0 +1,45 @@ + + +

Downloading and Installing OBS SDK for Python

+

This topic provides the download links and installation methods of OBS SDK for Python.

+

Downloading OBS SDK for Python

Latest version of OBS Python SDK source code: Download

+
+

Installing OBS SDK for Python

You can use the methods listed in Table 1 to install OBS SDK for Python.

+ +
+ + + + + + + + + + +
Table 1 Methods of installing OBS SDK for Python

No.

+

Method

+

1

+

Installing Using the Source Code

+

2

+

Installing the SDK Using setuptools

+
+
+
+

Method: Installing the SDK Using the Source Code

The following procedures show an example of installing the latest version of OBS Python SDK.

+
+
  1. the SDK package and decompress it.
  2. Run pip install pycryptodome==3.10.1 to install the cryptographic library.
  3. Decompress the development package to obtain folder src (SDK source code), folder examples (sample code), file README.txt (feature description file of SDK versions), and file log.conf (SDK log configuration file).
  4. Use PyCharm to create a project, copy the folders and files obtained in the previous step to the project, right-click folder src, and choose Mark Directory as > Sources Root.

    After the configuration, the directory structure is similar to the following:

    +

    ├── examples

    +

    ├── src

    +

    ├── log.conf

    +

    └── README.md

    +
    +

+

Method: Installing the SDK Using setuptools

The following procedures show an example of installing the latest version of OBS Python SDK.

+
+
  1. the SDK package and decompress it.
  2. Download and install setuptools.
  3. On the command-line interface (CLI), go to folder src under the directory where the development package is decompressed.
  4. Run the python setup.py install command to install the SDK.
  5. After the installation, check whether a folder named esdk_obs_python-<versionId>-*.egg is generated in Lib/site-package under the Python installation directory.

    • If you use this method to install the SDK, you need to delete folder esdk_obs_python-<versionId>-*.egg when you re-install the SDK.
    • If SDK modules cannot be loaded after you have performed the previous steps, you can directly add the absolute path of the src directory in OBS Python SDK to the sys.path list.
    +
    +

+
+
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0500.html b/docs/obs_3rd_party/python_sdk/obs_22_0500.html new file mode 100644 index 000000000..7e3cd40e8 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0500.html @@ -0,0 +1,228 @@ + + +

Getting Started with OBS SDK for Python

+

Creating an AK and SK

OBS employs access keys (AK and SK) for signature verification to ensure that only authorized accounts can access specified OBS resources. Detailed explanations of access keys are as follows:

+ +

Access keys are permanent. There are also temporary security credentials (consisting of an AK/SK pair and a security token). Each user can create a maximum of two valid AK/SK pairs. Temporary security credentials can only be used to access OBS within the specified validity period. Once they expire, they must be requested again. For security purposes, you are advised to use temporary security credentials to access OBS. If you want to use permanent access keys, periodically update them.

+ +
+ +

Obtaining Endpoints

+

The SDK allows you to pass endpoints with or without the protocol name. Suppose the endpoint you obtained is your-endpoint. The endpoint passed when initializing an instance of ObsClient can be http://your-endpoint, https://your-endpoint, or your-endpoint.

+
+
+

Initializing an Instance of ObsClient

Each time you want to send an HTTP/HTTPS request to OBS, you must create an ObsClient instance. Sample code is as follows:
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
# Import the module.
+from obs import ObsClient
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+# Use the instance to access OBS.
+
+# Close ObsClient.
+obsClient.close()
+
+
+
+

For more information, see chapter Initialization.

+

For details about log configuration, see Log Initialization (SDK for Python).

+
+
+

Creating a Bucket

A bucket is a global namespace of OBS and is a data container. It functions as a root directory of a file system and can store objects.

+

This example creates a bucket named examplebucket and specifies its location, ACL, storage class, and redundancy type.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
from obs import CreateBucketHeader, HeadPermission
+from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    # Add additional headers to specify a private bucket in the Standard storage class that supports multi-AZ storage.
+    header = CreateBucketHeader(aclControl=HeadPermission.PRIVATE, storageClass="STANDARD", availableZone="3az")
+    # Specify the region where the bucket is to be created. The region must be the same as that in the endpoint passed.
+    location = "region"
+    bucketName = "examplebucket"
+    # Create a bucket.
+    resp = obsClient.createBucket(bucketName, header, location)
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Create Bucket Succeeded')
+        print('requestId:', resp.requestId)
+    else:
+        print('Create Bucket Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Create Bucket Failed')
+    print(traceback.format_exc())
+
+
+
  • Bucket names are globally unique. Ensure that the bucket you create is named differently from any other bucket.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name, no error will be reported and the bucket attributes comply with those specified in the first creation request.
  • For more information, see Creating a Bucket.
+
+
+
+

Uploading an Object

This example uploads a text.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+# Before running the sample code, ensure that the environment variables AccessKeyID and SecretAccessKey have been configured.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName = "examplebucket"
+    objectKey = "objectname"
+    # Specify the text to be uploaded.
+    content = 'Hello OBS'
+    # Upload the text.
+    resp = obsClient.putContent(bucketName, objectKey, content)
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Put Content Succeeded')
+        print('requestId:', resp.requestId)
+        print('etag:', resp.body.etag)
+    else:
+        print('Put Content Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Put Content Failed')
+    print(traceback.format_exc())
+
+
+

For more information, see Object Upload Overview.

+
+
+
+
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0501.html b/docs/obs_3rd_party/python_sdk/obs_22_0501.html new file mode 100644 index 000000000..98ffbb850 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0501.html @@ -0,0 +1,14 @@ + + +

Object Upload Overview (SDK for Python)

+

You can use this API to upload an object to a specified bucket. In OBS, objects are basic data units that you can operate. OBS Python SDK provides many APIs for uploading objects using various methods:

+ +

SDK supports the upload of objects whose size ranges from 0 KB to 5 GB. For streaming upload, append upload, and file-based upload, data to be uploaded in a batch cannot be larger than 5 GB. If the file is larger than 5 GB, multipart upload (whose part size is smaller than 5 GB) is suitable. Browser-based upload allows files to be uploaded through a browser.

+

If you grant anonymous users the read permission for an object during the upload, anonymous users can access the object through a URL after the upload succeeds. The object URL is in the format of https://bucket name.domain name/directory levels/object name. If the object resides in the root directory of a bucket, its URL does not contain a directory level.

+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0502.html b/docs/obs_3rd_party/python_sdk/obs_22_0502.html new file mode 100644 index 000000000..bf7dd70e2 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0502.html @@ -0,0 +1,12 @@ + + +

Object Download Overview (SDK for Python)

+

OBS Python SDK provides abundant APIs for downloading objects using various methods:

+ +
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0600.html b/docs/obs_3rd_party/python_sdk/obs_22_0600.html new file mode 100644 index 000000000..267787597 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0600.html @@ -0,0 +1,17 @@ + + +

Initialization (SDK for Python)

+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0601.html b/docs/obs_3rd_party/python_sdk/obs_22_0601.html new file mode 100644 index 000000000..7d4e5d13d --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0601.html @@ -0,0 +1,276 @@ + + +

Initializing an Instance of ObsClient (SDK for Python)

+

Function

ObsClient functions as the Python client for accessing OBS. It offers users a series of APIs for interaction with OBS. These APIs are used for managing resources, such as buckets and objects, stored in OBS.

+
+

Method

ObsClient(access_key_id, secret_access_key, server)
+
+

Constructor Parameter Description

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Parameter

+

Description

+

Recommended Value

+

access_key_id

+

Access key ID (AK). It is left blank by default, which indicates that anonymous users are allowed for access.

+

N/A

+

secret_access_key

+

Secret access key (SK). It is left blank by default, which indicates that anonymous users are allowed for access.

+

N/A

+

security_token

+

Security token in the temporary access keys.

+

N/A

+

server

+

Server address for accessing OBS. It consists of a protocol type, domain name, and port number, for example, https://your-endpoint:443. For security purposes, you are advised to use HTTPS.

+

N/A

+

max_retry_count

+

Maximum number of retries when an HTTP/HTTPS connection is abnormal. The default value is 3.

+

[1,5]

+

max_redirect_count

+

Maximum number of times that the HTTP/HTTPS request is redirected. The default value is 10.

+

[1,10]

+

timeout

+

Timeout period (in seconds) of an HTTP/HTTPS request. The default value is 60.

+

[10,60]

+

ssl_verify

+

Client-to-server certificate verification used to check whether the client certificate matches the server certificate. The options are as follows:

+
  • Path to the server-side root certificate file in PEM format
  • True: The certificate list will be obtained from the root certificate library and the certificates of the operating system (Windows only) will be verified.
  • False: The server-side certificates will not be verified.
+

The default value is False.

+

N/A

+

chunk_size

+

Chunk size (in bytes) set for reading and writing socket streams. The default value is 65536.

+

Default

+

long_conn_mode

+

Whether to enable the persistent connection mode. The default value is False.

+

N/A

+

proxy_host

+

Host IP address of the proxy server. This value is left blank by default.

+
NOTE:

Do not specify http:// or https:// for the proxy server's host address.

+
+

N/A

+

proxy_port

+

Port number of the proxy server. This value is left blank by default.

+

N/A

+

proxy_username

+

User name used for connecting to the proxy server. This value is left blank by default.

+

N/A

+

proxy_password

+

Password used for connecting to the proxy server. This value is left blank by default.

+

N/A

+

is_cname

+

Whether to use a user-defined domain name to access OBS. The default value is False.

+

N/A

+

security_providers

+

How an access key is obtained. The default value is None.

+
NOTE:

The value of security_providers must be in a list. The default value None indicates the default search methods to obtain the access keys from the environment variables or from ECSs.

+

If this parameter is specified, the default search methods are not provided. Instead, the search methods specified by security_providers are used.

+
+

N/A

+

security_provider_policy

+

Specifies the allowed access key search policy. The default value is None.

+
NOTE:
  • This parameter is used to set the search policy. The default value None indicates the specified access keys are displayed. In addition, if the access key parameters are specified, security_provider_policy is ignored.
  • If security_provider_policy is set to OBS_DEFAULT, the access keys are obtained by searching in sequence.
  • If security_provider_policy is set to the predefined methods (ENV or ECS), the access keys are obtained using the corresponding method.
+
+

N/A

+
+
+
  • Parameters whose recommended value is N/A need to be set according to the actual conditions.
  • If the network is unstable, you are advised to set a larger value for timeout.
  • If the value of server does not contain any protocol, HTTPS is used by default.
+
+
  • If the persistent connection mode is enabled, you must call ObsClient.close to close ObsClient explicitly to reclaim connection resources.
  • For the sake of high DNS resolution performance and OBS reliability, you can set server only to the domain name of OBS, instead of the IP address.
+
+
+

Code Examples

+
  • The project can contain one or more instances of ObsClient.
+
  • ObsClient is thread secure and can be simultaneously used by multiple threads.
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0602.html b/docs/obs_3rd_party/python_sdk/obs_22_0602.html new file mode 100644 index 000000000..cb8279f71 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0602.html @@ -0,0 +1,69 @@ + + +

Initializing a BucketClient Instance (SDK for Python)

+

Function

BucketClient functions as the Python client for accessing an OBS bucket. It offers users a series of APIs for interaction with OBS. These APIs are used for managing resources, such as buckets and objects, stored in OBS.

+

Except for ObsClient.listBuckets, ObsClient.downloadFile, Obsclient.uploadFile, ObsClient.createPostSignature, and ObsClient.createSignedUrl, BucketClient implements the same APIs as ObsClient, including the same functions and parameters, with the bucketName parameter omitted.

+
+

Method

obsClient.bucketClient(
+    bucketName='*** Your Bucket Name ***'
+)
+
+

Constructor Parameter Description

+
+ + + + + + + + + + + +

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucket_name

+

str

+

Yes

+

Name of the bucket client to be created

+
+
+
+

Code Examples

# Import the module.
+from obs import ObsClient
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+
+# Create an instance of BucketClient.
+bucketClient = obsClient.bucketClient('bucketname')
+# Create a Bucket.
+resp = bucketClient.createBucket()
+if resp.status < 300:    
+    print('requestId:', resp.requestId)
+else:    
+    print('errorCode:', resp.errorCode)
+    print('errorMessage:', resp.errorMessage)
+

Except for ObsClient.listBuckets, ObsClient.downloadFile, Obsclient.uploadFile, ObsClient.createPostSignature, and ObsClient.createSignedUrl, BucketClient can implement the same APIs as ObsClient, including the same functions and parameters, with the bucketName parameter omitted.

+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0603.html b/docs/obs_3rd_party/python_sdk/obs_22_0603.html new file mode 100644 index 000000000..ad0d324c3 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0603.html @@ -0,0 +1,137 @@ + + +

Log Initialization (SDK for Python)

+

Function

You can enable the SDK log function to record log information generated during API calling into log files for subsequent data analysis or fault location. The procedure is as follows:

+
  1. Find file log.conf in the OBS Python SDK. The content format is as follows:
    [LOGCONF]
    +
    +#Configure log file dir
    +LogFileDir 			= ./logs
    +
    +#Configure log file name
    +LogFileName 		= eSDK-OBS-PYTHON.log
    +
    +#Configure log file size, unit:MB
    +LogFileSize     	= 30
    +
    +#Configure max log file numbers
    +LogFileNumber   	= 5
    +
    +#Configure log level for log file (DEBUG | INFO | WARNING | ERROR)
    +LogFileLevel    	= INFO
    +
    +#Configure whether to print log to console (Yes:1 No:0)
    +PrintLogToConsole   = 0
    +
    +#Configure log level for console (DEBUG | INFO | WARNING | ERROR)
    +PrintLogLevel		= WARNING
    +
  2. Modify parameters in the log.conf file as needed.
  3. Call ObsClient.initLog to enable the logging function.
+
  • The logging function is disabled by default. You need to enable it manually.
  • For details about SDK logs, see Log Analysis.
  • You can change the log file permissions in the system based on your actual needs.
+
+

The log module of the OBS Python SDK is thread secure but not process secure. If ObsClient is used in multi-process scenarios, you must configure an independent log path for each instance of ObsClient to prevent conflicts when multiple processes write logs concurrently.

+
+
+

Method

obsClient.initLog(
+    log_config='*** Your Log Configuration Parameters ***',
+    log_name='*** Your Log Name ***'
+)
+

+
+

Constructor Parameter Description

+
+ + + + + + + + + + + + + + + + +

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

log_config

+

LogConf

+

Yes

+

Log configuration parameter

+

log_name

+

str

+

No

+

Log name

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 1 LogConf

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

config_file

+

str

+

Yes

+

Path to the log configuration file

+

sec

+

str

+

No

+

Section name in the log configuration file. The default value is LOGCONF.

+
+
+
+

Code Examples

# Import the module.
+from obs import ObsClient
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+
+# Import the log module.
+from obs import LogConf
+
+# Specify the path to the log configuration file and initialize logs of ObsClient.
+obsClient.initLog(LogConf('./log.conf'), '*** Your Log Name ***')
+
+# Use ObsClient to access OBS.
+
+# Disable ObsClient logging.
+obsClient.close()
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0604.html b/docs/obs_3rd_party/python_sdk/obs_22_0604.html new file mode 100644 index 000000000..e50f867ea --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0604.html @@ -0,0 +1,154 @@ + + +

SDK Common Results (SDK for Python)

+

Function

Each time an ObsClient related API is called (excluding ObsClient.createSignedUrl and ObsClient.createPostSignature), an SDK common result object will be returned. You can obtain the HTTP status code from this object to check whether the operation is successful.

+
+

Parameter Description

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+
The following is an example of a successful returned result:
{
+    'status': 200,
+    'reason': 'OK',
+    'body': {
+	...The details are omitted here.
+    },
+    'requestId': '000001************B5512',
+    'header': [...The header is omitted.]
+}
+
+

Code Examples

+
try:
+    resp = obsClient.getObject('bucketname', 'objectname', loadStreamInMemory=True) 
+          
+    if resp.status < 300: 
+        print('requestId:', resp.requestId)
+        # Obtain the object content.
+        print('buffer:', resp.body.buffer) 
+        print('size:', resp.body.size) 
+    else: 
+        print('errorCode:', resp.errorCode) 
+        print('errorMessage:', resp.errorMessage)
+except:
+    import traceback
+    print(traceback.format_exc())
+

In a binary download, if loadStreamInMemory is set to True, the object content is contained in the body.buffer parameter in the returned result.

+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0800.html b/docs/obs_3rd_party/python_sdk/obs_22_0800.html new file mode 100644 index 000000000..f5cfd526a --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0800.html @@ -0,0 +1,77 @@ + + +

Bucket-Related APIs (SDK for Python)

+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0801.html b/docs/obs_3rd_party/python_sdk/obs_22_0801.html new file mode 100644 index 000000000..79b8c117b --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0801.html @@ -0,0 +1,569 @@ + + +

Creating a Bucket (SDK for Python)

+

Function

This API creates an OBS bucket. Buckets are containers for storing objects (files uploaded to OBS) in OBS.

+

When creating a bucket, you can also configure parameters such as the storage class, region, and access control as needed.

+
+

Restrictions

+
+

Method

ObsClient.createBucket(bucketName, header, location, extensionHeaders)

+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
+

Default value:

+

None

+

header

+

CreateBucketHeader

+

No

+

Explanation:

+

Headers in the request used for configuring the storage class, redundancy policy, and other basic information about the bucket

+

Value range:

+

See Table 2.

+

Default value:

+

None

+

location

+

str

+

Yes if the region where the OBS service resides is not the default region

+

Explanation:

+

Region where a bucket will be created.

+

Value range:

+

To learn about valid regions and endpoints, see Regions and Endpoints. An endpoint is the request address for calling an API. Endpoints vary depending on services and regions. To obtain the regions and endpoints, contact the enterprise administrator.

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 CreateBucketHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

aclControl

+

str

+

No

+

Explanation:

+

Access control list (ACL) that can be pre-defined during bucket creation

+

Value range:

+

See Table 3.

+

Default value:

+

PRIVATE

+

storageClass

+

str

+

No

+

Explanation:

+

Bucket storage class that can be pre-defined during bucket creation

+

Value range:

+

See Table 4.

+

Default value:

+

STANDARD

+

extensionGrants

+

list of ExtensionGrant

+

No

+

Explanation:

+

Extended permission list that can be specified during bucket creation

+

Value range:

+

See Table 5.

+

Default value:

+

None

+

epid

+

str

+

No

+

Explanation:

+

Enterprise project ID that can be specified during bucket creation. If you have enabled Enterprise Project Management Service (EPS), you can obtain the project ID from the EPS console.

+

Restrictions:

+

The value of Epid is a Universally Unique Identifier (UUID). Epid is not required if you have not enabled EPS yet.

+

Example: 9892d768-2d13-450f-aac7-ed0e44c2585f

+

Default value:

+

None

+

isPFS

+

bool

+

No

+

Explanation:

+

Whether a parallel file system is created

+

Value range:

+
  • True: A parallel file system is created.
  • False: A bucket is created.
+

Default value:

+

False

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 HeadPermission

Constant

+

Default Value

+

Description

+

HeadPermission.PRIVATE

+

private

+

Private read/write

+

A bucket or object can only be accessed by its owner.

+

HeadPermission.PUBLIC_READ

+

public-read

+

Public read and private write

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, metadata, and object versions in the bucket.

+

If it is granted on an object, anyone can read the content and metadata of the object.

+

HeadPermission.PUBLIC_READ_WRITE

+

public-read-write

+

Public read/write

+

If this permission is granted on a bucket, anyone can read the object list, multipart tasks, metadata, and object versions in the bucket, and can upload or delete objects, initiate multipart upload tasks, upload parts, assemble parts, copy parts, and abort multipart upload tasks.

+

If it is granted on an object, anyone can read the content and metadata of the object.

+

HeadPermission.PUBLIC_READ_DELIVERED

+

public-read-delivered

+

Public read on a bucket as well as objects in the bucket

+

If this permission is granted on a bucket, anyone can read the object list, multipart tasks, metadata, and object versions, and read the content and metadata of objects in the bucket.

+
NOTE:

PUBLIC_READ_DELIVERED cannot be applied to objects.

+
+

HeadPermission.PUBLIC_READ_WRITE_DELIVERED

+

public-read-write-delivered

+

Public read/write on a bucket as well as objects in the bucket

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, metadata, and object versions in the bucket, and can upload or delete objects, initiate multipart upload tasks, upload parts, assemble parts, copy parts, and abort multipart uploads. They can also read the content and metadata of objects in the bucket.

+
NOTE:

PUBLIC_READ_WRITE_DELIVERED cannot be applied to objects.

+
+

HeadPermission.BUCKET_OWNER_FULL_CONTROL

+

public-read-write-delivered

+

If this permission is granted on an object, only the bucket and object owners have the full control over the object. By default, if you upload an object to a bucket of any other user, the bucket owner does not have the permissions on your object. After you grant this policy to the bucket owner, the bucket owner can have full control over your object.

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 4 StorageClass

Parameter

+

Type

+

Description

+

STANDARD

+

Standard storage class

+

Explanation:

+

Features low access latency and high throughput and is used for storing massive, frequently accessed (multiple times a month) or small objects (< 1 MB) requiring quick response.

+

WARM

+

Warm storage class

+

Explanation:

+

Used for storing data that is semi-frequently accessed (fewer than 12 times a year) but is instantly available when needed.

+

COLD

+

Cold storage class

+

Explanation:

+

Used for storing rarely accessed (once a year) data.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 5 ExtensionGrant

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

granteeId

+

str

+

No

+

Explanation:

+

Account (domain) ID of the grantee

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and IAM User ID? (SDK for Python)

+

Default value:

+

None

+

permission

+

str

+

No

+

Explanation:

+

Custom permissions for the bucket

+

Value range:

+

You can select one or more permissions from Table 6.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
Table 6 Permission

Constant

+

Description

+

READ

+

Read permission

+

A grantee with this permission for a bucket can obtain the list of objects, multipart uploads, bucket metadata, and object versions in the bucket.

+

A grantee with this permission for an object can obtain the object content and metadata.

+

WRITE

+

Write permission

+

A grantee with this permission for a bucket can upload, overwrite, and delete any object or part in the bucket.

+

Such permission for an object is not applicable.

+

READ_ACP

+

Permission to read ACL configurations

+

A grantee with this permission can obtain the ACL of a bucket or object.

+

A bucket or object owner has this permission for the bucket or object permanently.

+

WRITE_ACP

+

Permission to modify ACL configurations

+

A grantee with this permission can update the ACL of a bucket or object.

+

A bucket or object owner has this permission for the bucket or object permanently.

+

A grantee with this permission can modify the access control policy and thus the grantee obtains full access permissions.

+

FULL_CONTROL

+

Full control access, including read and write permissions for a bucket and its ACL, or for an object and its ACL.

+

A grantee with this permission for a bucket has READ, WRITE, READ_ACP, and WRITE_ACP permissions for the bucket.

+

A grantee with this permission for an object has READ, READ_ACP, and WRITE_ACP permissions for the object.

+
+
+
+

Responses

+
+ + + + + + + +
Table 7 List of returned results

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 8 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+
+

Code Examples

This example creates a bucket named examplebucket and specifies its location, ACL, storage class, and redundancy type.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
from obs import CreateBucketHeader, HeadPermission
+from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    # Add additional headers to specify a private bucket in the Standard storage class that supports multi-AZ storage.
+    header = CreateBucketHeader(aclControl=HeadPermission.PRIVATE, storageClass="STANDARD", availableZone="3az")
+    # Specify the region where the bucket is to be created. The region must be the same as that in the endpoint passed.
+    location = "region"
+    bucketName = "examplebucket"
+    # Create a bucket.
+    resp = obsClient.createBucket(bucketName, header, location)
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Create Bucket Succeeded')
+        print('requestId:', resp.requestId)
+    else:
+        print('Create Bucket Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Create Bucket Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0802.html b/docs/obs_3rd_party/python_sdk/obs_22_0802.html new file mode 100644 index 000000000..2afcb3b3f --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0802.html @@ -0,0 +1,420 @@ + + +

Obtaining a Bucket List (SDK for Python)

+

Function

OBS buckets are containers for storing objects you upload to OBS. This API returns a list of all buckets that meet the specified conditions in all regions of the current account. Returned buckets are listed in alphabetical order by bucket name.

+
+

Restrictions

+
+

Method

ObsClient.listBuckets(isQueryLocation, extensionHeaders)

+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

isQueryLocation

+

bool

+

No

+

Explanation:

+

Whether to query the bucket location

+

Value range:

+
  • True: The bucket location is queried.
  • False: The bucket location is not queried.
+

Default value:

+

False

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + +
Table 2 List of returned results

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+
+ +
+ + + + + + + +
Table 4 GetResult.body

GetResult.body Type

+

Description

+

ListBucketsResponse

+

Explanation:

+

Returned results for obtaining the bucket list. For details, see Table 5.

+
+
+ +
+ + + + + + + + + + + + + +
Table 5 ListBucketsResponse

Parameter

+

Type

+

Description

+

buckets

+

list of Bucket

+

Explanation:

+

List of buckets

+

Value range:

+

See Table 6.

+

owner

+

Owner

+

Explanation:

+

Bucket owner

+

Value range:

+

See Table 7.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 6 Bucket

Parameter

+

Type

+

Description

+

name

+

str

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
+

Default value:

+

None

+

create_date

+

str

+

Explanation:

+

Time when the bucket was created.

+

Default value:

+

None

+

location

+

str

+

Explanation:

+

Region where a bucket is located

+

Value range:

+

To learn about valid regions and endpoints, see Regions and Endpoints. An endpoint is the request address for calling an API. Endpoints vary depending on services and regions. To obtain the regions and endpoints, contact the enterprise administrator.

+

bucket_type

+

str

+

Explanation:

+

Bucket type.

+

Value range:

+
  • Object bucket: OBJECT
  • Parallel file system: POSIX
+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 7 Owner

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

owner_id

+

str

+

Yes if used as a request parameter

+

Explanation:

+

Account (domain) ID of the owner

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and IAM User ID? (SDK for Python)

+

Default value:

+

None

+

owner_name

+

str

+

No if used as a request parameter

+

Explanation:

+

Account name of the owner

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and IAM User ID? (SDK for Python)

+

Default value:

+

None

+
+
+

Code Examples

This example lists all buckets and queries the bucket region.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+# List buckets and set isQueryLocation to True to query the bucket region.
+    resp = obsClient.listBuckets(True)
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('List Buckets Succeeded')
+        print('requestId:', resp.requestId)
+        print('name:', resp.body.owner.owner_id)
+        print('create_date:', resp.body.owner.owner_name)
+        index = 1
+        for bucket in resp.body.buckets:
+            print('bucket [' + str(index) + ']')
+            print('name:', bucket.name)
+            print('create_date:', bucket.create_date)
+            print('location:', bucket.location)
+            index += 1
+    else:
+        print('List Buckets Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('List Buckets Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0803.html b/docs/obs_3rd_party/python_sdk/obs_22_0803.html new file mode 100644 index 000000000..299f8808c --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0803.html @@ -0,0 +1,266 @@ + + +

Checking Whether a Bucket Exists (SDK for Python)

+

Function

This API checks whether a bucket exists. If an HTTP status code 200 is returned, the bucket exists. If 404 is returned, the bucket does not exist.

+
+

Restrictions

+
+

Method

ObsClient.headBucket(bucketName, extensionHeaders)

+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + +
Table 2 List of returned results

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+
+

Code Examples

This example checks whether bucket examplebucket exists.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName="examplebucket"
+    # Check whether the bucket exists.
+    resp = obsClient.headBucket(bucketName)
+    # If status code 2xx is returned, the API was called successfully. Otherwise, the call failed.
+    if resp.status < 300:
+        print('Head Bucket Succeeded')
+        print('Bucket exists')
+    elif resp.status == 404:
+        print('Head Bucket Failed')
+        print('Bucket does not exist')
+    else:
+        print('Head Bucket Failed')
+        print('status:', resp.status)
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Head Bucket Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0804.html b/docs/obs_3rd_party/python_sdk/obs_22_0804.html new file mode 100644 index 000000000..da94e370d --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0804.html @@ -0,0 +1,259 @@ + + +

Deleting a Bucket (SDK for Python)

+

Function

This API deletes an empty bucket. You can delete buckets you no longer use to free up space. The name of a deleted bucket can be reused for another bucket at least 30 minutes after the deletion.

+
+

Restrictions

+
+

Method

ObsClient.deleteBucket(bucketName, extensionHeaders)

+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + +
Table 2 List of returned results

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+
+

Code Examples

This example deletes bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName="examplebucket"
+    # Delete the bucket.
+    resp = obsClient.deleteBucket(bucketName)
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Delete Bucket Succeeded')
+        print('requestId:', resp.requestId)
+    else:
+        print('Delete Bucket Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Delete Bucket Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0805.html b/docs/obs_3rd_party/python_sdk/obs_22_0805.html new file mode 100644 index 000000000..046bd32b0 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0805.html @@ -0,0 +1,776 @@ + + +

Listing Objects in a Bucket (SDK for Python)

+

Function

This API lists some or all of the objects in a bucket. You can use parameters such as the prefix, number of returned objects, and start position to list objects that meet specified criteria. Returned objects are listed in alphabetical order by object name.

+
+

Restrictions

+
+

Method

ObsClient.listObjects(bucketName, prefix, marker, max_keys, delimiter, extensionHeaders)

+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

prefix

+

str

+

No

+

Explanation:

+

Name prefix that the objects to be listed must contain.

+

Assume that you have the following objects: logs/day1, logs/day2, logs/day3, and ExampleObject.jpg. If you specify logs/ as the prefix, logs/day1, logs/day2, and logs/day3 will be returned. If you leave this parameter blank, all objects in the bucket will be returned.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

marker

+

str

+

No

+

Explanation:

+

Name of the object to start with when listing objects in a bucket. All objects following this object are listed in alphabetical order by object name.

+

Assume that you have the following objects: test/a, test/b, test/c, and test/d. If you specify test/b as the marker, test/c and test/d are returned.

+

Restrictions:

+

This parameter is only used for listing objects with a single version.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

max_keys

+

int

+

No

+

Explanation:

+

The maximum number of objects returned in the response in alphabetical order

+

Value range:

+

The value ranges from 1 to 1000. If the specified value is greater than 1000, only 1,000 objects are returned.

+

Default value:

+

1000

+

delimiter

+

str

+

No

+

Explanation:

+

This parameter is used to group object names. If a prefix is specified, objects with the same string from the prefix to the first delimiter are grouped into one CommonPrefix. If no prefix is specified, objects with the same string from the first character to the first delimiter are grouped into one CommonPrefix.

+

Assume that a bucket has objects abcd, abcde, and bbcde in it. If delimiter is set to d and prefix is set to a, objects abcd and abcde are grouped into a CommonPrefix with abcd as the prefix. If only delimiter is set to d, objects abcd and abcde are grouped into a CommonPrefix with abcd as the prefix, and bbcde is grouped separately into another CommonPrefix with bbcd as the prefix.

+

For a parallel file system, if this parameter is not specified, all the content in the directory is recursively listed by default, including the content in subdirectories. In big data scenarios, parallel file systems usually have multiple directory levels and each directory level has a large number of files. In such case, you are advised to configure [delimiter=/] to list the content in the current directory but exclude the content in subdirectories, thereby making the listing more efficient.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + +
Table 2 List of returned results

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + +
Table 4 GetResult.body

GetResult.body Type

+

Description

+

ListObjectsResponse

+

Explanation:

+

See Table 5.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 5 ListObjectsResponse

Parameter

+

Type

+

Description

+

name

+

str

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

location

+

str

+

Explanation:

+

Region where a bucket is located

+

Value range:

+

To learn about valid regions and endpoints, see Regions and Endpoints. An endpoint is the request address for calling an API. Endpoints vary depending on services and regions. To obtain the regions and endpoints, contact the enterprise administrator.

+

prefix

+

str

+

Explanation:

+

Name prefix that the objects to be listed must contain.

+

Assume that you have the following objects: logs/day1, logs/day2, logs/day3, and ExampleObject.jpg. If you specify logs/ as the prefix, logs/day1, logs/day2, and logs/day3 will be returned. If you leave this parameter blank, all objects in the bucket will be returned.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

marker

+

str

+

Explanation:

+

Name of the object to start with when listing objects in a bucket. All objects following this object are listed in alphabetical order by object name.

+

Assume that you have the following objects: test/a, test/b, test/c, and test/d. If you specify test/b as the marker, test/c and test/d are returned.

+

Restrictions:

+

This parameter is only used for listing objects with a single version.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

delimiter

+

str

+

Explanation:

+

This parameter is used to group object names. If a prefix is specified, objects with the same string from the prefix to the first delimiter are grouped into one CommonPrefix. If no prefix is specified, objects with the same string from the first character to the first delimiter are grouped into one CommonPrefix.

+

Assume that a bucket has objects abcd, abcde, and bbcde in it. If delimiter is set to d and prefix is set to a, objects abcd and abcde are grouped into a commonPrefix with abcd as the prefix. If only delimiter is set to d, objects abcd and abcde are grouped into a commonPrefix with abcd as the prefix, and bbcde is grouped separately into another commonPrefix with bbcd as the prefix.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

max_keys

+

int

+

Explanation:

+

The maximum number of objects returned in the response in alphabetical order

+

Value range:

+

The value ranges from 1 to 1000. If the specified value is greater than 1000, only 1,000 objects are returned.

+

Default value:

+

1000

+

is_truncated

+

bool

+

Explanation:

+

Whether all results are returned in the response

+

Value range:

+
  • True indicates that not all results are returned.
  • False indicates that all results are returned.
+

Default value:

+

None

+

next_marker

+

str

+

Explanation:

+

Object name to start with upon next request for listing objects

+

Value range:

+

An object name string

+

Default value:

+

None

+

contents

+

list of Content

+

Explanation:

+

List of objects in the bucket

+

Value range:

+

See Table 6.

+

commonPrefixs

+

list of CommonPrefix

+

Explanation:

+

List of object name prefixes grouped according to the delimiter parameter (if specified)

+

Value range:

+

See Table 8.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 6 Content

Parameter

+

Type

+

Description

+

key

+

str

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

lastModified

+

str

+

Explanation:

+

Time when the last modification was made to the object

+

Restrictions:

+

The time must be in the ISO8601 format.

+

Example: 2018-01-01T00:00:00.000Z

+

Default value:

+

None

+

etag

+

str

+

Explanation:

+

Base64-encoded, 128-bit MD5 value of an object. ETag is the unique identifier of the object contents and is used to determine whether the contents of an object are changed. For example, if the ETag value is A when an object is uploaded and is B when the object is downloaded, this indicates the contents of the object are changed. The ETag reflects changes only to the contents of an object, not its metadata. Objects created by the upload and copy operations have unique ETags after being encrypted using MD5.

+

Restrictions:

+

If an object is encrypted using server-side encryption, the ETag is not the MD5 value of the object.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

size

+

int

+

Explanation:

+

Object size

+

Value range:

+

The value ranges from 0 TB to 48.8 TB, in bytes.

+

Default value:

+

None

+

owner

+

Owner

+

Explanation:

+

Object owner

+

Value range:

+

See Table 7.

+

storageClass

+

str

+

Explanation:

+

Storage class of the object

+

Value range:

+
  • If the storage class is Standard, leave this parameter blank.
  • For details about the available storage classes, see Table 9.
+

Default value:

+

None

+

isAppendable

+

bool

+

Explanation:

+

Whether the object is appendable

+

Value range:

+

True: The object is appendable.

+

False: The object is not appendable.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 7 Owner

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

owner_id

+

str

+

Yes if used as a request parameter

+

Explanation:

+

Account (domain) ID of the owner

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and IAM User ID? (SDK for Python)

+

Default value:

+

None

+

owner_name

+

str

+

No if used as a request parameter

+

Explanation:

+

Account name of the owner

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and IAM User ID? (SDK for Python)

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + +
Table 8 CommonPrefix

Parameter

+

Type

+

Description

+

prefix

+

str

+

Explanation:

+

List of object name prefixes grouped according to the delimiter parameter (if specified)

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 9 StorageClass

Parameter

+

Type

+

Description

+

STANDARD

+

Standard storage class

+

Explanation:

+

Features low access latency and high throughput and is used for storing massive, frequently accessed (multiple times a month) or small objects (< 1 MB) requiring quick response.

+

WARM

+

Warm storage class

+

Explanation:

+

Used for storing data that is semi-frequently accessed (fewer than 12 times a year) but is instantly available when needed.

+

COLD

+

Cold storage class

+

Explanation:

+

Used for storing rarely accessed (once a year) data.

+
+
+
+

Code Examples

All elements stored in OBS buckets are called objects. Folders are objects whose sizes are 0 and whose names end with a slash (/). You can use the folder name as the prefix to list objects in a folder. This example lists objects with test/ as the prefix in bucket examplebucket. A maximum of 100 objects can be returned at a time.
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName = "examplebucket"
+    # Specify an object prefix.
+    prefix = 'test/'
+    # Specify the maximum number of objects to be listed at a time. 100 is used as an example.
+    max_keys = 100
+    # List objects in the bucket.
+    resp = obsClient.listObjects(bucketName, prefix, max_keys=max_keys, encoding_type='url')
+
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('List Objects Succeeded')
+        print('requestId:', resp.requestId)
+        print('name:', resp.body.name)
+        print('prefix:', resp.body.prefix)
+        print('max_keys:', resp.body.max_keys)
+        print('is_truncated:', resp.body.is_truncated)
+        index = 1
+        for content in resp.body.contents:
+            print('object [' + str(index) + ']')
+            print('key:', content.key)
+            print('lastModified:', content.lastModified)
+            print('etag:', content.etag)
+            print('size:', content.size)
+            print('storageClass:', content.storageClass)
+            print('owner_id:', content.owner.owner_id)
+            print('owner_name:', content.owner.owner_name)
+            index += 1
+    else:
+        print('List Objects Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('List Objects Failed')
+    print(traceback.format_exc())
+
+
+
+
+

Sample Code (for Listing over 1,000 Objects)

 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
try:
+    max_num = 1000
+    mark = None
+    index = 1 
+    while True:
+        resp = obsClient.listObjects('bucketname', marker=mark, max_keys=max_num, encoding_type='url')
+        if resp.status < 300: 
+            print('requestId:', resp.requestId) 
+            print('name:', resp.body.name) 
+            print('prefix:', resp.body.prefix) 
+            print('max_keys:', resp.body.max_keys) 
+            print('is_truncated:', resp.body.is_truncated) 
+            for content in resp.body.contents: 
+                print('object [' + str(index) + ']') 
+                print('key:', content.key) 
+                print('lastModified:', content.lastModified) 
+                print('etag:', content.etag) 
+                print('size:', content.size) 
+                print('storageClass:', content.storageClass) 
+                print('owner_id:', content.owner.owner_id) 
+                print('owner_name:', content.owner.owner_name) 
+                index += 1 
+            if resp.body.is_truncated is True:
+                mark = resp.body.next_marker
+            else:
+                break
+        else: 
+            print('errorCode:', resp.errorCode) 
+            print('errorMessage:', resp.errorMessage)
+            break
+except:
+    import traceback
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0806.html b/docs/obs_3rd_party/python_sdk/obs_22_0806.html new file mode 100644 index 000000000..407cc3798 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0806.html @@ -0,0 +1,912 @@ + + +

Listing Object Versions in a Bucket (SDK for Python)

+

Function

This API lists some or all of the object versions in a bucket. You can use parameters such as the prefix, number of returned object versions, and start position to list the object versions that meet specified criteria. Returned object versions are listed in alphabetical order by object name.

+
+

Restrictions

+
+

Method

ObsClient.listVersions(bucketName, version, extensionHeaders)

+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

version

+

Versions

+

No

+

Explanation:

+

Object name to start with when listing object versions in a bucket. All object versions following this parameter are listed in alphabetical order.

+

Restrictions:

+

This parameter is only used for listing objects with multiple versions.

+

Value range:

+

See Table 2.

+

Default value:

+

None

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 Versions

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

prefix

+

str

+

No

+

Explanation:

+

Name prefix that the objects to be listed must contain

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

key_marker

+

str

+

No

+

Explanation:

+

Object name to start with when listing object versions in a bucket. All object versions following the value specified by this parameter are listed in alphabetical order.

+

Restrictions:

+

This parameter is only used for listing objects with multiple versions.

+

Value range:

+

The value of nextKeyMarker in the response body of the last request

+

Default value:

+

None

+

max_keys

+

int

+

or

+

str

+

No

+

Explanation:

+

The maximum number of objects returned in the response in alphabetical order

+

Value range:

+

The value ranges from 1 to 1000. If the specified value is greater than 1000, only 1,000 objects are returned.

+

Default value:

+

1000

+

delimiter

+

str

+

No

+

Explanation:

+

This parameter is used to group object names. If a prefix is specified, objects with the same string from the prefix to the first delimiter are grouped into one CommonPrefix. If no prefix is specified, objects with the same string from the first character to the first delimiter are grouped into one CommonPrefix.

+

Assume that a bucket has objects abcd, abcde, and bbcde in it. If delimiter is set to d and prefix is set to a, objects abcd and abcde are grouped into a CommonPrefix with abcd as the prefix. If only delimiter is set to d, objects abcd and abcde are grouped into a CommonPrefix with abcd as the prefix, and bbcde is grouped separately into another CommonPrefix with bbcd as the prefix.

+

For a parallel file system, if this parameter is not specified, all the content in the directory is recursively listed by default, including the content in subdirectories. In big data scenarios, parallel file systems usually have multiple directory levels and each directory level has a large number of files. In such case, you are advised to configure [delimiter=/] to list the content in the current directory but exclude the content in subdirectories, thereby making the listing more efficient.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

version_id_marker

+

str

+

No

+

Explanation:

+

Version ID to start with when listing objects in a bucket. All objects are listed in alphabetical order by object name and version ID. This parameter must be used together with key_marker. key_marker specifies the object name, and version_id_marker specifies the version of the specified object.

+

Restrictions:

+
  • This parameter is only used for listing objects with multiple versions.
  • If the value of version_id_marker is not a version ID specified by key_marker, version_id_marker does not take effect.
+

Value range:

+

Object version ID, that is, the value of nextVersionIdMarker in the response body of the last request

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + +
Table 3 List of returned results

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 4 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + +
Table 5 GetResult.body

GetResult.body Type

+

Description

+

ObjectVersions

+

Explanation:

+

Response to the request for listing object versions in a bucket

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 6 ObjectVersions

Parameter

+

Type

+

Description

+

head

+

ObjectVersionHead

+

Explanation:

+

Response header of the request for listing object versions in a bucket

+

Value range:

+

See Table 7.

+

versions

+

list of ObjectVersion

+

Explanation:

+

List of object versions in the bucket

+

Value range:

+

See Table 8.

+

markers

+

list of ObjectDeleteMarker

+

Explanation:

+

List of delete markers in the bucket

+

Value range:

+

See Table 9.

+

commonPrefixs

+

list of CommonPrefix

+

Explanation:

+

List of object name prefixes grouped according to the delimiter parameter (if specified)

+

Value range:

+

See Table 11.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 7 ObjectVersionHead

Parameter

+

Type

+

Description

+

name

+

str

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

location

+

str

+

Explanation:

+

Region where a bucket is located

+

Value range:

+

To learn about valid regions and endpoints, see Regions and Endpoints. An endpoint is the request address for calling an API. Endpoints vary depending on services and regions. To obtain the regions and endpoints, contact the enterprise administrator.

+

delimiter

+

str

+

Explanation:

+

This parameter is used to group object names. If a prefix is specified, objects with the same string from the prefix to the first delimiter are grouped into one commonPrefix. If no prefix is specified, objects with the same string from the first character to the first delimiter are grouped into one commonPrefix.

+

Assume that a bucket has objects abcd, abcde, and bbcde in it. If delimiter is set to d and prefix is set to a, objects abcd and abcde are grouped into a commonPrefix with abcd as the prefix. If only delimiter is set to d, objects abcd and abcde are grouped into a commonPrefix with abcd as the prefix, and bbcde is grouped separately into another commonPrefix with bbcd as the prefix.

+

For a parallel file system, if this parameter is not specified, all the content in the directory is recursively listed by default, including the content in subdirectories. In big data scenarios, parallel file systems usually have multiple directory levels and each directory level has a large number of files. In such case, you are advised to configure [delimiter=/] to list the content in the current directory but exclude the content in subdirectories, thereby making the listing more efficient.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

prefix

+

str

+

Explanation:

+

Name prefix that the objects to be listed must contain

+

Assume that you have the following objects: logs/day1, logs/day2, logs/day3, and ExampleObject.jpg. If you specify logs/ as the prefix, logs/day1, logs/day2, and logs/day3 will be returned. If you leave this parameter blank, all objects in the bucket will be returned.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

keyMarker

+

str

+

Explanation:

+

Object name to start with for listing object versions

+

Restrictions:

+

This parameter is only used for listing objects with multiple versions.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

versionIdMarker

+

str

+

Explanation:

+

Version ID to start with for listing versioning objects, which is consistent with that set in the request

+

Restrictions:

+

This parameter is only used for listing objects with multiple versions.

+

Value range:

+

The value must contain 32 characters.

+

nextKeyMarker

+

str

+

Explanation:

+

Object name to start with for the next request for listing object versions

+

Value range:

+

An object name string

+

nextVersionIdMarker

+

str

+

Explanation:

+

Version ID to start with upon the next request for listing object versions. It is used with the nextKeyMarker parameter.

+

Value range:

+

The value must contain 32 characters.

+

maxKeys

+

int

+

Explanation:

+

The maximum number of objects returned in the response in alphabetical order

+

Value range:

+

The value ranges from 1 to 1000. If the specified value is greater than 1000, only 1,000 objects are returned.

+

Default value:

+

1000

+

isTruncated

+

bool

+

Explanation:

+

Whether all results are returned in the response

+

Value range:

+
  • True indicates that not all results are returned.
  • False indicates that all results are returned.
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 8 ObjectVersion

Parameter

+

Type

+

Description

+

key

+

str

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

versionId

+

str

+

Explanation:

+

Object version ID

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

lastModified

+

str

+

Explanation:

+

Time when the last modification was made to the object

+

Restrictions:

+

The time must be in the ISO8601 format, for example, 2018-01-01T00:00:00.000Z.

+

Default value:

+

None

+

etag

+

str

+

Explanation:

+

Base64-encoded, 128-bit MD5 value of an object. ETag is the unique identifier of the object contents and is used to determine whether the contents of an object are changed. For example, if the ETag value is A when an object is uploaded and is B when the object is downloaded, this indicates the contents of the object are changed. The ETag reflects changes only to the contents of an object, not its metadata. Objects created by the upload and copy operations have unique ETags after being encrypted using MD5.

+

Restrictions:

+

If an object is encrypted using server-side encryption, the ETag is not the MD5 value of the object.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

size

+

int

+

Explanation:

+

Object size

+

Value range:

+

The value ranges from 0 TB to 48.8 TB, in bytes.

+

Default value:

+

None

+

owner

+

Owner

+

Explanation:

+

Object owner

+

Value range:

+

See Table 10.

+

storageClass

+

str

+

Explanation:

+

Storage class of the object

+

Value range:

+
  • If the storage class is Standard, leave this parameter blank.
  • For details about the available storage classes, see Table 12.
+

isLatest

+

bool

+

Explanation:

+

Whether the object is of the latest version

+

Value range:

+
  • True indicates that the version is the latest.
  • False indicates that the version is not the latest.
+

Default value:

+

None

+

isAppendable

+

bool

+

Explanation:

+

Whether the object is an appendable object

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Table 9 ObjectDeleteMarker

Parameter

+

Type

+

Description

+

key

+

str

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

versionId

+

str

+

Explanation:

+

Object version ID

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

isLatest

+

bool

+

Explanation:

+

Whether the object is of the latest version

+

Value range:

+
  • True indicates that the version is the latest.
  • False indicates that the version is not the latest.
+

Default value:

+

None

+

lastModified

+

str

+

Explanation:

+

Time when the last modification was made to the object

+

Restrictions:

+

The time must be in the ISO8601 format, for example, 2018-01-01T00:00:00.000Z.

+

Default value:

+

None

+

owner

+

Owner

+

Explanation:

+

Object owner

+

Value range:

+

See Table 10.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 10 Owner

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

owner_id

+

str

+

Yes if used as a request parameter

+

Explanation:

+

Account (domain) ID of the owner

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and IAM User ID? (SDK for Python)

+

Default value:

+

None

+

owner_name

+

str

+

No if used as a request parameter

+

Explanation:

+

Account name of the owner

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and IAM User ID? (SDK for Python)

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + +
Table 11 CommonPrefix

Parameter

+

Type

+

Description

+

prefix

+

str

+

Explanation:

+

List of object name prefixes grouped according to the delimiter parameter (if specified)

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 12 StorageClass

Parameter

+

Type

+

Description

+

STANDARD

+

Standard storage class

+

Explanation:

+

Features low access latency and high throughput and is used for storing massive, frequently accessed (multiple times a month) or small objects (< 1 MB) requiring quick response.

+

WARM

+

Warm storage class

+

Explanation:

+

Used for storing data that is semi-frequently accessed (fewer than 12 times a year) but is instantly available when needed.

+

COLD

+

Cold storage class

+

Explanation:

+

Used for storing rarely accessed (once a year) data.

+
+
+
+

Code Examples

This example lists the first 100 objects with test/ as the prefix in bucket examplebucket in alphabetical order.
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
from obs import ObsClient
+from obs import Versions
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName="examplebucket"
+    # Specify an object prefix.
+    prefix='test/'
+    max_keys=100
+    # List object versions in a bucket.
+    resp = obsClient.listVersions(bucketName, version=Versions(prefix, max_keys, encoding_type='url'))
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('List Versions Succeeded')
+        print('requestId:', resp.requestId)
+        print('name:', resp.body.head.name)
+        print('prefix:', resp.body.head.prefix)
+        print('maxKeys:', resp.body.head.maxKeys)
+        print('isTruncated:', resp.body.head.isTruncated)
+        index = 1
+        for version in resp.body.versions:
+            print('version [' + str(index) + ']')
+            print('key:', version.key)
+            print('versionId:', version.versionId)
+            print('lastModified:', version.lastModified)
+            print('etag:', version.etag)
+            print('size:', version.size)
+            print('storageClass:', version.storageClass)
+            print('owner_id:', version.owner.owner_id)
+            print('owner_name:', version.owner.owner_name)
+            index += 1
+
+        index = 1
+        for marker in resp.body.markers:
+            print('marker [' + str(index) + ']')
+            print('key:', marker.key)
+            print('versionId:', marker.versionId)
+            print('lastModified:', marker.lastModified)
+            print('owner_id:', marker.owner.owner_id)
+            print('owner_name:', marker.owner.owner_name)
+            index += 1
+    else:
+        print('List Versions Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('List Versions Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0807.html b/docs/obs_3rd_party/python_sdk/obs_22_0807.html new file mode 100644 index 000000000..96da23272 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0807.html @@ -0,0 +1,490 @@ + + +

Obtaining Bucket Metadata (SDK for Python)

+

Function

This API returns information about a bucket, including the storage class, region, CORS rules, and redundancy policy.

+
+

Restrictions

+
+

Method

ObsClient.getBucketMetadata(bucketName, origin, requestHeaders, extensionHeaders)

+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

origin

+

str

+

No

+

Explanation:

+

Origin of the cross-domain request specified by the preflight request. Generally, it is a domain name.

+

Restrictions:

+

You can configure one or more rules and use at most one wildcard character (*) in each rule. If you want to configure multiple rules, separate them using a line breaker.

+

Default value:

+

None

+

requestHeaders

+

str

+

No

+

Explanation:

+

HTTP headers in a cross-origin request Only CORS requests matching the allowed headers are valid.

+

Restrictions:

+

You can enter multiple allowed headers, with one separated from another using a line break. Each header can contain one wildcard character (*) at most. Spaces, ampersands (&), colons (:), and less-than signs (<) are not allowed.

+

Default value:

+

None

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + +
Table 2 List of returned results

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + +
Table 4 GetResult.body

GetResult.body Type

+

Description

+

GetBucketMetadataResponse

+

Explanation:

+

Response to the request for obtaining bucket metadata

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 5 GetBucketMetadataResponse

Parameter

+

Type

+

Description

+

location

+

str

+

Explanation:

+

Region where a bucket is located

+

Value range:

+

To learn about valid regions and endpoints, see Regions and Endpoints. An endpoint is the request address for calling an API. Endpoints vary depending on services and regions. To obtain the regions and endpoints, contact the enterprise administrator.

+

storageClass

+

str

+

Explanation:

+

Storage class of the bucket. For details, see Table 6.

+

Default value:

+

None

+

accessContorlAllowOrigin

+

str

+

Explanation:

+

If Origin in the request meets the CORS rules of the bucket, AllowedOrigin specified in the CORS rules is returned. AllowedOrigin indicates the origin from which the requests can access the bucket.

+

Restrictions:

+

Domain name of the origin. Each origin can contain only one wildcard character (*), for example, https://*.vbs.example.com.

+

Default value:

+

None

+

accessContorlAllowHeaders

+

str

+

Explanation:

+

If RequestHeader in the request meets the CORS rules of the bucket, AllowedHeader specified in the CORS rules is returned. AllowedHeader indicates the allowed headers for cross-origin requests. Only CORS requests matching the allowed headers are valid.

+

Restrictions:

+

Each header can contain only one wildcard character (*). Spaces, ampersands (&), colons (:), and less-than signs (<) are not allowed.

+

Default value:

+

None

+

accessContorlAllowMethods

+

str

+

Explanation:

+

AllowedMethod in the CORS rules of the bucket. It specifies the HTTP method of cross-origin requests, that is, the operation type of buckets and objects.

+

Value range:

+

The following HTTP methods are supported:

+
  • GET
  • PUT
  • HEAD
  • POST
  • DELETE
+

Default value:

+

None

+

accessContorlExposeHeaders

+

str

+

Explanation:

+

ExposeHeader in the CORS rules of the bucket. It specifies the CORS-allowed additional headers in the response. These headers provide additional information to clients. By default, your browser can only access headers Content-Length and Content-Type. If your browser needs to access other headers, add them to a list of the allowed additional headers.

+

Restrictions:

+

Spaces, wildcard characters (*), ampersands (&), colons (:), and less-than signs (<) are not allowed.

+

Default value:

+

None

+

accessContorlMaxAge

+

int

+

Explanation:

+

MaxAgeSeconds in the CORS rules of the bucket. It specifies the time your client can cache the response for a cross-origin request.

+

Restrictions:

+

Each CORS rule can contain only one MaxAgeSeconds.

+

Value range:

+

An integer greater than or equal to 0, in seconds

+

Default value:

+

100

+

obsVersion

+

str

+

Explanation:

+

OBS version of the bucket

+

Value range:

+
  • 3.0 indicates the latest OBS version.
  • -- indicates any version earlier than 3.0.
+

Default value:

+

None

+

availableZone

+

str

+

Explanation:

+

Data redundancy type that can be specified during bucket creation

+

Restrictions:

+

Multi-AZ redundancy is not available for Cold storage. If the region where the bucket is located does not support multi-AZ storage, single-AZ storage is used by default.

+

Value range:

+

If multi-AZ storage is configured for the bucket, 3az is returned. If single-AZ storage is configured for the bucket, None is returned.

+

Default value:

+

None

+

epid

+

str

+

Explanation:

+

Enterprise project ID that can be specified during bucket creation. If you have enabled Enterprise Project Management Service (EPS), you can obtain the project ID from the EPS console.

+

Restrictions:

+

The value of Epid is a UUID. Epid is not required if you have not enabled EPS yet.

+

Example: 9892d768-2d13-450f-aac7-ed0e44c2585f

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 6 StorageClass

Parameter

+

Type

+

Description

+

STANDARD

+

Standard storage class

+

Explanation:

+

Features low access latency and high throughput and is used for storing massive, frequently accessed (multiple times a month) or small objects (< 1 MB) requiring quick response.

+

WARM

+

Warm storage class

+

Explanation:

+

Used for storing data that is semi-frequently accessed (fewer than 12 times a year) but is instantly available when needed.

+

COLD

+

Cold storage class

+

Explanation:

+

Used for storing rarely accessed (once a year) data.

+
+
+
+

Code Examples

This example returns the metadata of bucket examplebucket. The origin of the cross-origin request is http://www.a.com and the HTTP header is x-obs-header.
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName="examplebucket"
+    # Specify the origin (usually a domain name) of the cross-origin request.
+    origin='http://www.a.com'
+    # Specify the HTTP headers of the cross-origin request.
+    requestHeaders='x-obs-header'
+    # Obtain the bucket metadata.
+    resp = obsClient.getBucketMetadata(bucketName,origin,requestHeaders)
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Get Bucket Metadata Succeeded')
+        print('requestId:', resp.requestId)
+        print('storageClass:', resp.body.storageClass)
+        print('accessContorlAllowOrigin:', resp.body.accessContorlAllowOrigin)
+        print('accessContorlMaxAge:', resp.body.accessContorlMaxAge)
+        print('accessContorlExposeHeaders:', resp.body.accessContorlExposeHeaders)
+        print('accessContorlAllowMethods:', resp.body.accessContorlAllowMethods)
+        print('accessContorlAllowHeaders:', resp.body.accessContorlAllowHeaders)
+    else:
+        print('Get Bucket Metadata Failed')
+        print('requestId:', resp.requestId)
+        print('status:', resp.status)
+except:
+    print('Get Bucket Metadata Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0808.html b/docs/obs_3rd_party/python_sdk/obs_22_0808.html new file mode 100644 index 000000000..17af46ed6 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0808.html @@ -0,0 +1,299 @@ + + +

Obtaining the Region of a Bucket (SDK for Python)

+

Function

This API returns the region of a bucket.

+
+

Restrictions

+
+

Method

ObsClient.getBucketLocation(bucketName, extensionHeaders)

+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + +
Table 2 List of returned results

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + +
Table 4 GetResult.body

GetResult.body Type

+

Description

+

LocationResponse

+

Explanation:

+

Response to the request for obtaining a bucket location

+
+
+ +
+ + + + + + + + + +
Table 5 LocationResponse

Parameter

+

Type

+

Description

+

location

+

str

+

Explanation:

+

Region where a bucket is located

+

Value range:

+

To learn about valid regions and endpoints, see Regions and Endpoints. An endpoint is the request address for calling an API. Endpoints vary depending on services and regions. To obtain the regions and endpoints, contact the enterprise administrator.

+
+
+

+
+

Code Examples

This example returns the region where bucket examplebucket is located.
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName="examplebucket"
+    # Obtain the bucket region.
+    resp = obsClient.getBucketLocation(bucketName)
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Get Bucket Location Succeeded')
+        print('requestId:', resp.requestId)
+        print('location:', resp.body.location)
+    else:
+        print('Get Bucket Location Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Get Bucket Location Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0809.html b/docs/obs_3rd_party/python_sdk/obs_22_0809.html new file mode 100644 index 000000000..ecbf80c7c --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0809.html @@ -0,0 +1,312 @@ + + +

Obtaining Storage Information of a Bucket (SDK for Python)

+

Function

This API returns the storage information of a bucket, including the number of objects and the space occupied by the objects in the bucket.

+

OBS measures bucket storage statistics in the background and does not update the storage information in real time. So, you are advised not to perform real-time verification on the storage information.

+
+
+

Restrictions

+
+

Method

ObsClient.getBucketStorageInfo(bucketName, extensionHeaders)

+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + +
Table 2 List of returned results

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + +
Table 4 GetResult.body

GetResult.body Type

+

Description

+

GetBucketStorageInfoResponse

+

Explanation:

+

Response result of the request for obtaining storage information about a bucket

+
+
+ +
+ + + + + + + + + + + + + +
Table 5 GetBucketStorageInfoResponse

Parameter

+

Type

+

Description

+

size

+

long

+

Explanation:

+

Bucket size

+

Default value:

+

None

+

objectNumber

+

int

+

Explanation:

+

Number of objects in the bucket

+

Default value:

+

None

+
+
+
+

Code Examples

This example returns the storage information of bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName="examplebucket"
+    # Obtain bucket storage information.
+    resp = obsClient.getBucketStorageInfo(bucketName)
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Get Bucket StorageInfo Succeeded')
+        print('requestId:', resp.requestId)
+        print('size:', resp.body.size)
+        print('objectNumber:', resp.body.objectNumber)
+    else:
+        print('Get Bucket StorageInfo Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Get Bucket StorageInfo Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0810.html b/docs/obs_3rd_party/python_sdk/obs_22_0810.html new file mode 100644 index 000000000..364ebe761 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0810.html @@ -0,0 +1,279 @@ + + +

Configuring a Storage Quota (SDK for Python)

+

Function

A quota limits the maximum capacity allowed in a bucket. By default, there is no limit on the storage capacity of the entire OBS system or a single bucket, and any number of objects can be stored. You can set a storage quota to control the total size of objects that can be uploaded to the bucket. After the storage quota has been reached, object upload will fail.

+

A quota limit does not apply to the objects uploaded before the quota is configured. If the specified quota is already smaller than the total size of existing objects in the bucket, the existing objects in the bucket will not be deleted, but no more object can be uploaded to the bucket later. In this case, to upload new objects, you must delete some existing objects to make the used space below the quota limit.

+
+

Restrictions

+
+

Method

ObsClient.setBucketQuota(bucketName, quota, extensionHeaders)

+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

quota

+

int

+

Yes

+

Explanation:

+

Bucket quota

+

Value range:

+

An integer greater than or equal to 0, in bytes

+

Default value:

+

0, indicating that there is no limit on the bucket quota.

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + +
Table 2 List of returned results

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+
+

Code Examples

This example configures a 1 GB quota for bucket examplebucket.
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName = "examplebucket"
+    # Specify a 1 GB quota (measured in bytes) for the bucket.
+    quota = 1024 * 1024 * 1024
+    # Configure a quota for the bucket.
+    resp = obsClient.setBucketQuota(bucketName, quota)
+
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Set Bucket Quota Succeeded')
+        print('requestId:', resp.requestId)
+    else:
+        print('Set Bucket Quota Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Set Bucket Quota Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0811.html b/docs/obs_3rd_party/python_sdk/obs_22_0811.html new file mode 100644 index 000000000..1d976fa4e --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0811.html @@ -0,0 +1,300 @@ + + +

Obtaining a Bucket Storage Quota (SDK for Python)

+

Function

This API returns the storage quota (upper limit of the storage capacity) of a bucket. If the quota is 0, there is no upper limit on the bucket capacity.

+
+

Restrictions

+
+

Method

ObsClient.getBucketQuota(bucketName, extensionHeaders)

+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + +
Table 2 List of returned results

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + +
Table 4 GetResult.body

GetResult.body Type

+

Description

+

GetBucketQuotaResponse

+

Explanation:

+

Response result of the request for obtaining the storage capacity quota of a bucket

+
+
+ +
+ + + + + + + + + +
Table 5 GetBucketQuotaResponse

Parameter

+

Type

+

Description

+

quota

+

int

+

Explanation:

+

Bucket quota

+

Value range:

+

An integer greater than or equal to 0, in bytes

+

Default value:

+

0, indicating that there is no limit on the bucket quota.

+
+
+
+

Code Examples

This example returns the quota of bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName="examplebucket"
+    # Obtain the bucket quota.
+    resp = obsClient.getBucketQuota(bucketName)
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Get Bucket Quota Succeeded')
+        print('requestId:', resp.requestId)
+        print('quota:', resp.body.quota)
+    else:
+        print('Get Bucket Quota Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Get Bucket Quota Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0812.html b/docs/obs_3rd_party/python_sdk/obs_22_0812.html new file mode 100644 index 000000000..5df2e8b8c --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0812.html @@ -0,0 +1,314 @@ + + +

Configuring a Storage Class for a Bucket (SDK for Python)

+

Function

This API configures a storage class for a bucket. If you do not specify a storage class when uploading or copying an object, or initiating a multipart upload, the object inherits the bucket's storage class.

+
+

Restrictions

+
+

Method

ObsClient.setBucketStoragePolicy(bucketName, storageClass, extensionHeaders)

+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + +

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

storageClass

+

str

+

Yes

+

Explanation:

+

Storage class of the bucket

+

Value range:

+

See Table 1.

+

Default value:

+

None

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 1 StorageClass

Parameter

+

Type

+

Description

+

STANDARD

+

Standard storage class

+

Explanation:

+

Features low access latency and high throughput and is used for storing massive, frequently accessed (multiple times a month) or small objects (< 1 MB) requiring quick response.

+

WARM

+

Warm storage class

+

Explanation:

+

Used for storing data that is semi-frequently accessed (fewer than 12 times a year) but is instantly available when needed.

+

COLD

+

Cold storage class

+

Explanation:

+

Used for storing rarely accessed (once a year) data.

+
+
+
+

Responses

+
+ + + + + + + +

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+
+

Code Examples

This example sets the storage class of bucket examplebucket to Standard.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName = "examplebucket"
+    # Set the storage class of the bucket to Standard.
+    storageClass = 'STANDARD'
+    # Configure the storage class for the bucket.
+    resp = obsClient.setBucketStoragePolicy(bucketName, storageClass)
+
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Set Bucket StoragePolicy Succeeded')
+        print('requestId:', resp.requestId)
+    else:
+        print('Set Bucket StoragePolicy Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Set Bucket StoragePolicy Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0813.html b/docs/obs_3rd_party/python_sdk/obs_22_0813.html new file mode 100644 index 000000000..d6e4fd9ce --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0813.html @@ -0,0 +1,332 @@ + + +

Obtaining the Storage Class of a Bucket (SDK for Python)

+

Function

This API returns the storage class of a bucket.

+
+

Restrictions

+
+

Method

ObsClient.getBucketStoragePolicy(bucketName, extensionHeaders)

+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + +

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + +

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + +

GetResult.body Type

+

Description

+

GetBucketStoragePolicyResponse

+

Explanation:

+

Response to the request for obtaining the storage class of a bucket

+
+
+ +
+ + + + + + + + + +
Table 2 GetBucketStoragePolicyResponse

Parameter

+

Type

+

Description

+

storageClass

+

str

+

Explanation:

+

Storage class of the bucket

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 3 StorageClass

Parameter

+

Type

+

Description

+

STANDARD

+

Standard storage class

+

Explanation:

+

Features low access latency and high throughput and is used for storing massive, frequently accessed (multiple times a month) or small objects (< 1 MB) requiring quick response.

+

WARM

+

Warm storage class

+

Explanation:

+

Used for storing data that is semi-frequently accessed (fewer than 12 times a year) but is instantly available when needed.

+

COLD

+

Cold storage class

+

Explanation:

+

Used for storing rarely accessed (once a year) data.

+
+
+
+

Code Examples

This example returns the storage class of bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName="examplebucket"
+    # Obtain the bucket's storage class.
+    resp = obsClient.getBucketStoragePolicy(bucketName)
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Get Bucket StoragePolicy Succeeded')
+        print('requestId:', resp.requestId)
+        print('storageClass:', resp.body.storageClass)
+    else:
+        print('Get Bucket StoragePolicy Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Get Bucket StoragePolicy Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0814.html b/docs/obs_3rd_party/python_sdk/obs_22_0814.html new file mode 100644 index 000000000..5c9f0ee6d --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0814.html @@ -0,0 +1,677 @@ + + +

Configuring a Bucket ACL (SDK for Python)

+

Function

OBS provides access control over buckets. You can use an access policy to define whether a user can perform certain operations on a specific bucket. OBS access control can be implemented using IAM permissions, bucket policies, and ACLs (including bucket and object ACLs).

+

A bucket ACL grants permissions to another account and its IAM users, rather than the current account and its IAM users. It can grant access to both a bucket (including the objects in it) and the bucket ACL. The granted access includes view and edit permissions. You must specify a bucket name when configuring a bucket ACL.

+

This API modifies a bucket ACL.

+
+

Restrictions

+
+

Method

ObsClient.setBucketAcl(bucketName, acl, aclControl, extensionHeaders)

+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

acl

+

ACL

+

No

+

Explanation:

+

Bucket ACL

+

Value range:

+

See Table 1.

+

Default value:

+

None

+
NOTE:

acl and aclControl are mutually exclusive.

+
+

aclControl

+

str

+

No

+

Explanation:

+

Pre-defined ACL

+

Value range:

+

See Table 3.

+

Default value:

+

None

+
NOTE:

acl and aclControl are mutually exclusive.

+
+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 1 ACL

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

owner

+

Owner

+

Yes if used as a request parameter

+

Explanation:

+

Bucket owner information. For details, see Table 4.

+

Restrictions:

+

Owner and Grants must be used together and they cannot be used with aclControl.

+

Default value:

+

None

+

grants

+

list of Grant

+

Yes if used as a request parameter

+

Explanation:

+

List of grantees' permission information. For details, see Table 5.

+

Default value:

+

None

+

delivered

+

bool

+

No if used as a request parameter

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket

+

Value range:

+

True: The bucket ACL is applied to all objects in the bucket.

+

False: The bucket ACL is not applied to all objects in the bucket.

+

Default value:

+

False

+

+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
Table 2 Permission

Constant

+

Description

+

READ

+

Read permission

+

A grantee with this permission for a bucket can obtain the list of objects, multipart uploads, bucket metadata, and object versions in the bucket.

+

A grantee with this permission for an object can obtain the object content and metadata.

+

WRITE

+

Write permission

+

A grantee with this permission for a bucket can upload, overwrite, and delete any object or part in the bucket.

+

Such permission for an object is not applicable.

+

READ_ACP

+

Permission to read ACL configurations

+

A grantee with this permission can obtain the ACL of a bucket or object.

+

A bucket or object owner has this permission for the bucket or object permanently.

+

WRITE_ACP

+

Permission to modify ACL configurations

+

A grantee with this permission can update the ACL of a bucket or object.

+

A bucket or object owner has this permission for the bucket or object permanently.

+

A grantee with this permission can modify the access control policy and thus the grantee obtains full access permissions.

+

FULL_CONTROL

+

Full control access, including read and write permissions for a bucket and its ACL, or for an object and its ACL.

+

A grantee with this permission for a bucket has READ, WRITE, READ_ACP, and WRITE_ACP permissions for the bucket.

+

A grantee with this permission for an object has READ, READ_ACP, and WRITE_ACP permissions for the object.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 HeadPermission

Constant

+

Default Value

+

Description

+

HeadPermission.PRIVATE

+

private

+

Private read/write

+

A bucket or object can only be accessed by its owner.

+

HeadPermission.PUBLIC_READ

+

public-read

+

Public read and private write

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, metadata, and object versions in the bucket.

+

If it is granted on an object, anyone can read the content and metadata of the object.

+

HeadPermission.PUBLIC_READ_WRITE

+

public-read-write

+

Public read/write

+

If this permission is granted on a bucket, anyone can read the object list, multipart tasks, metadata, and object versions in the bucket, and can upload or delete objects, initiate multipart upload tasks, upload parts, assemble parts, copy parts, and abort multipart upload tasks.

+

If it is granted on an object, anyone can read the content and metadata of the object.

+

HeadPermission.PUBLIC_READ_DELIVERED

+

public-read-delivered

+

Public read on a bucket as well as objects in the bucket

+

If this permission is granted on a bucket, anyone can read the object list, multipart tasks, metadata, and object versions, and read the content and metadata of objects in the bucket.

+
NOTE:

PUBLIC_READ_DELIVERED cannot be applied to objects.

+
+

HeadPermission.PUBLIC_READ_WRITE_DELIVERED

+

public-read-write-delivered

+

Public read/write on a bucket as well as objects in the bucket

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, metadata, and object versions in the bucket, and can upload or delete objects, initiate multipart upload tasks, upload parts, assemble parts, copy parts, and abort multipart uploads. They can also read the content and metadata of objects in the bucket.

+
NOTE:

PUBLIC_READ_WRITE_DELIVERED cannot be applied to objects.

+
+

HeadPermission.BUCKET_OWNER_FULL_CONTROL

+

public-read-write-delivered

+

If this permission is granted on an object, only the bucket and object owners have the full control over the object. By default, if you upload an object to a bucket of any other user, the bucket owner does not have the permissions on your object. After you grant this policy to the bucket owner, the bucket owner can have full control over your object.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 4 Owner

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

owner_id

+

str

+

Yes if used as a request parameter

+

Explanation:

+

Account (domain) ID of the owner

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and IAM User ID? (SDK for Python)

+

Default value:

+

None

+

owner_name

+

str

+

No if used as a request parameter

+

Explanation:

+

Account name of the owner

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and IAM User ID? (SDK for Python)

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 5 Grant

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantee

+

Grantee

+

Yes if used as a request parameter

+

Explanation:

+

Grantee information. For details, see Table 6.

+

permission

+

str

+

Yes if used as a request parameter

+

Explanation:

+

Granted permission

+

Value range:

+

You can select one or more permissions from Table 2.

+

Default value:

+

None

+

delivered

+

bool

+

No if used as a request parameter

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket

+

Value range:

+

True: The bucket ACL is applied to all objects in the bucket.

+

False: The bucket ACL is not applied to all objects in the bucket.

+

Default value:

+

False

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 6 Grantee

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantee_id

+

str

+

Yes if the parameter is used as a request parameter and group is left blank

+

Explanation:

+

Account (domain) ID of the grantee.

+

Default value:

+

None

+

grantee_name

+

str

+

No if used as a request parameter

+

Explanation:

+

Username of the grantee. For details, see How Do I Get My Account ID and IAM User ID? (SDK for Python)

+

Restrictions:

+
  • Cannot contain full-width characters.
  • Starts with a letter.
  • Contains 6 to 32 characters.
  • Contains only letters, digits, hyphens (-), and underscores (_).
+

Default value:

+

None

+

group

+

str

+

Yes if the parameter is used as a request parameter and grantee_id is left blank

+

Explanation:

+

Authorized user group

+

Value range:

+

See Table 7.

+

Default value:

+

None

+
+
+

The authorized entity can be an individual user or a user group. grantee_id and grantee_name must be used together and they cannot be used with group.

+
+ +
+ + + + + + + + + + + + + +
Table 7 Group

Constant

+

Description

+

ALL_USERS

+

All users

+

AUTHENTICATED_USERS

+

Authorized users. This constant is deprecated.

+

LOG_DELIVERY

+

Log delivery group. This constant is deprecated.

+
+
+

Responses

+
+ + + + + + + +

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 8 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+
+

Code Examples

This example sets the ACL permission control for bucket examplebucket to public read for all users and to read and write for an IAM user (userid).
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
from obs import ObsClient, HeadPermission
+from obs import ACL
+from obs import Owner
+from obs import Grantee
+from obs import Grant
+from obs import Group
+from obs import Permission
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    # Specify the account ID of the bucket owner (ownerid as an example).
+    owner_id = 'ownerid'
+    owner = Owner(owner_id=owner_id)
+    # Specify the IAM user ID (userid).
+    grantee1 = Grantee(grantee_id='userid')
+    # Specify all users.
+    grantee2 = Grantee(group=Group.ALL_USERS)
+    # Grant the read and write permissions to the specified IAM user.
+    grant1 = Grant(grantee=grantee1, permission=Permission.READ)
+    grant2 = Grant(grantee=grantee1, permission=Permission.WRITE)
+    # Grant the read permission to all users.
+    grant3 = Grant(grantee=grantee2, permission=Permission.READ)
+    # Set the ACL permission control for bucket examplebucket to public read for all users and to read and write for the IAM user.
+    acl = ACL(owner=owner, grants=[grant1, grant2, grant3])
+    bucketName = "examplebucket"
+    # Configure the bucket ACL.
+    resp = obsClient.setBucketAcl(bucketName, acl)
+
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Set Bucket Acl Succeeded')
+        print('requestId:', resp.requestId)
+    else:
+        print('Set Bucket Acl Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Set Bucket Acl Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0815.html b/docs/obs_3rd_party/python_sdk/obs_22_0815.html new file mode 100644 index 000000000..ed2fb8835 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0815.html @@ -0,0 +1,569 @@ + + +

Obtaining a Bucket ACL (SDK for Python)

+

Function

OBS provides access control over buckets. You can use an access policy to define whether a user can perform certain operations on a specific bucket. OBS access control can be implemented using IAM permissions, bucket policies, and ACLs (including bucket and object ACLs).

+

A bucket ACL grants permissions to another account and its IAM users, rather than the current account and its IAM users. It can grant access to both a bucket (including the objects in it) and the bucket ACL. The granted access includes view and edit permissions. You must specify a bucket name when configuring a bucket ACL.

+

This API returns the ACL of a bucket.

+
+

Restrictions

+
+

Method

ObsClient.getBucketAcl(bucketName, extensionHeaders)

+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + +

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + +

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + +

GetResult.body Type

+

Description

+

ACL

+

Explanation:

+

Bucket ACL

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 2 ACL

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

owner

+

Owner

+

Yes if used as a request parameter

+

Explanation:

+

Bucket owner. For details, see Table 3.

+

grants

+

list of Grant

+

Yes if used as a request parameter

+

Explanation:

+

Grantees' permission information. For details, see Table 4.

+

delivered

+

bool

+

No if used as a request parameter

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket

+

Value range:

+

True: The bucket ACL is applied to all objects in the bucket.

+

False: The bucket ACL is not applied to all objects in the bucket.

+

Default value:

+

False

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 3 Owner

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

owner_id

+

str

+

Yes if used as a request parameter

+

Explanation:

+

Account (domain) ID of the owner

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and IAM User ID? (SDK for Python)

+

Default value:

+

None

+

owner_name

+

str

+

No if used as a request parameter

+

Explanation:

+

Account name of the owner

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and IAM User ID? (SDK for Python)

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 4 Grant

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantee

+

Grantee

+

Yes if used as a request parameter

+

Explanation:

+

Grantee information. For details, see Table 5.

+

Default value:

+

None

+

permission

+

str

+

Yes if used as a request parameter

+

Explanation:

+

Granted permission. For details, see Table 6.

+

Default value:

+

None

+

delivered

+

bool

+

No if used as a request parameter

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket

+

Value range:

+

True: The bucket ACL is applied to all objects in the bucket.

+

False: The bucket ACL is not applied to all objects in the bucket.

+

Default value:

+

False

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 5 Grantee

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantee_id

+

str

+

Yes if the parameter is used as a request parameter and group is left blank

+

Explanation:

+

Account (domain) ID of the grantee.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and IAM User ID? (SDK for Python)

+

Default value:

+

None

+

grantee_name

+

str

+

No if used as a request parameter

+

Explanation:

+

Username of the grantee.

+

Restrictions:

+
  • Cannot contain full-width characters.
  • Starts with a letter.
  • Contains 6 to 32 characters.
  • Contains only letters, digits, hyphens (-), and underscores (_).
+

Default value:

+

None

+

group

+

str

+

Yes if the parameter is used as a request parameter and grantee_id is left blank

+

Explanation:

+

Authorized user group

+

Value range:

+

See Table 7.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
Table 6 Permission

Constant

+

Description

+

READ

+

Read permission

+

A grantee with this permission for a bucket can obtain the list of objects, multipart uploads, bucket metadata, and object versions in the bucket.

+

A grantee with this permission for an object can obtain the object content and metadata.

+

WRITE

+

Write permission

+

A grantee with this permission for a bucket can upload, overwrite, and delete any object or part in the bucket.

+

Such permission for an object is not applicable.

+

READ_ACP

+

Permission to read ACL configurations

+

A grantee with this permission can obtain the ACL of a bucket or object.

+

A bucket or object owner has this permission for the bucket or object permanently.

+

WRITE_ACP

+

Permission to modify ACL configurations

+

A grantee with this permission can update the ACL of a bucket or object.

+

A bucket or object owner has this permission for the bucket or object permanently.

+

A grantee with this permission can modify the access control policy and thus the grantee obtains full access permissions.

+

FULL_CONTROL

+

Full control access, including read and write permissions for a bucket and its ACL, or for an object and its ACL.

+

A grantee with this permission for a bucket has READ, WRITE, READ_ACP, and WRITE_ACP permissions for the bucket.

+

A grantee with this permission for an object has READ, READ_ACP, and WRITE_ACP permissions for the object.

+
+
+

The authorized entity can be an individual user or a user group. grantee_id and grantee_name must be used together and they cannot be used with group.

+
+ +
+ + + + + + + + + + + + + +
Table 7 Group

Constant

+

Description

+

ALL_USERS

+

All users

+

AUTHENTICATED_USERS

+

Authorized users. This constant is deprecated.

+

LOG_DELIVERY

+

Log delivery group. This constant is deprecated.

+
+
+
+

Code Examples

This example returns the ACL information of bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName="examplebucket"
+    # Obtain the bucket ACL.
+    resp = obsClient.getBucketAcl(bucketName)
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Get Bucket Acl Succeeded')
+        print('requestId:', resp.requestId)
+        print('owner_id:', resp.body.owner.owner_id)
+        print('owner_name:', resp.body.owner.owner_name)
+        index = 1
+        for grant in resp.body.grants:
+            print('grant [' + str(index) + ']')
+            print('grant_id:', grant.grantee.grantee_id)
+            print('grant_name:', grant.grantee.grantee_name)
+            print('group:', grant.grantee.group)
+            print('permission:', grant.permission)
+            index += 1
+    else:
+        print('Get Bucket Acl Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Get Bucket Acl Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0816.html b/docs/obs_3rd_party/python_sdk/obs_22_0816.html new file mode 100644 index 000000000..23c82f9cc --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0816.html @@ -0,0 +1,556 @@ + + +

Configuring Logging for a Bucket (SDK for Python)

+

Function

This API enables logging for a bucket (source) and configures another bucket (target) to store the log files. When a bucket is created, logging is not enabled by default. You can call this API to enable logging for the bucket. With logging enabled, a log message is generated for each operation on the bucket. Multiple log messages are packed into a file. The bucket for storing log files must be specified when logging is enabled. It can be the bucket logging is enabled for, or any other bucket you have access to. If you specify another bucket for storing logs, the bucket must be in the same region as the logged bucket. You can also configure access to log files and the name prefix of log files.

+
+

Restrictions

+
+

Method

ObsClient.setBucketLogging(bucketName, logstatus, extensionHeaders)

+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + +

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

logstatus

+

Logging

+

No

+

Explanation:

+

Logging configuration information For details, see Table 1.

+

Default value:

+

None

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 Logging

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

targetBucket

+

str

+

No

+

Explanation:

+

Name of the bucket for storing log files

+

Restrictions:

+
  • This bucket must be in the same region as the bucket with logging enabled.
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

targetPrefix

+

str

+

No

+

Explanation:

+

Name prefix for log files stored in the log storage bucket

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

targetGrants

+

list of Grant

+

No

+

Explanation:

+

Permission information list of grantees, which defines grantees and their permissions for log files. For details, see Table 2.

+

Default value:

+

None

+

agency

+

str

+

Yes when configuring bucket logging

+

Explanation:

+

Name of the IAM agency created by the owner of the target bucket for OBS.

+

You can select an existing IAM agency or create one.

+

Restrictions:

+

By default, the IAM agency only requires the PutObject permission to upload logs to the target bucket. If default encryption is enabled for the target bucket, the agency also requires the KMS Administrator permission in the region where the target bucket is located.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 2 Grant

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantee

+

Grantee

+

Yes

+

Explanation:

+

Grantee information. For details, see Table 3.

+

permission

+

str

+

Yes

+

Explanation:

+

Granted permission

+

Value range:

+

See Table 4.

+

Default value:

+

None

+

delivered

+

bool

+

No

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket

+

Value range:

+

True: The bucket ACL is applied to all objects in the bucket.

+

False: The bucket ACL is not applied to all objects in the bucket.

+

Default value:

+

False

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 3 Grantee

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantee_id

+

str

+

Yes if group is left blank.

+

Explanation:

+

Account (domain) ID of the grantee.

+

+

Default value:

+

None

+

grantee_name

+

str

+

No

+

Explanation:

+

Username of the grantee.

+

Restrictions:

+
  • Starts with a letter. Contains 6 to 32 characters.
  • Contains only letters, digits, hyphens (-), and underscores (_).
+

Default value:

+

None

+

group

+

str

+

Yes if grantee_id is left blank.

+

Explanation:

+

Authorized user group

+

Value range:

+

See Table 5.

+

Default value:

+

None

+
+
+

The authorized entity can be an individual user or a user group. grantee_id and grantee_name must be used together and they cannot be used with group.

+
+ +
+ + + + + + + + + + + + + + + + + + + +
Table 4 Permission

Constant

+

Description

+

READ

+

Read permission

+

A grantee with this permission for a bucket can obtain the list of objects, multipart uploads, bucket metadata, and object versions in the bucket.

+

A grantee with this permission for an object can obtain the object content and metadata.

+

WRITE

+

Write permission

+

A grantee with this permission for a bucket can upload, overwrite, and delete any object or part in the bucket.

+

Such permission for an object is not applicable.

+

READ_ACP

+

Permission to read ACL configurations

+

A grantee with this permission can obtain the ACL of a bucket or object.

+

A bucket or object owner has this permission for the bucket or object permanently.

+

WRITE_ACP

+

Permission to modify ACL configurations

+

A grantee with this permission can update the ACL of a bucket or object.

+

A bucket or object owner has this permission for the bucket or object permanently.

+

A grantee with this permission can modify the access control policy and thus the grantee obtains full access permissions.

+

FULL_CONTROL

+

Full control access, including read and write permissions for a bucket and its ACL, or for an object and its ACL.

+

A grantee with this permission for a bucket has READ, WRITE, READ_ACP, and WRITE_ACP permissions for the bucket.

+

A grantee with this permission for an object has READ, READ_ACP, and WRITE_ACP permissions for the object.

+
+
+

+ +
+ + + + + + + + + + + + + +
Table 5 Group

Constant

+

Description

+

ALL_USERS

+

All users

+

AUTHENTICATED_USERS

+

Authorized users. This constant is deprecated.

+

LOG_DELIVERY

+

Log delivery group. This constant is deprecated.

+
+
+
+

Responses

+
+ + + + + + + +

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 6 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+
+

Code Examples

This example configures logging for bucket examplebucket and store log files in bucket targetbucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
from obs import ObsClient
+from obs import Grantee
+from obs import Grant
+from obs import Logging
+from obs import Permission
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    # Authorize the account ID (domain_id) of a user to read the bucket logs.
+    grantee1 = Grantee(grantee_id='domain_id')
+    grant1 = Grant(grantee=grantee1, permission=Permission.READ)
+    grantList = [grant1]
+    # Specify a bucket name for storing generated log files.
+    targetBucket = "targetBucket"
+    # Specify an object prefix, indicating the path for storing log files.
+    targetPrefix = 'test/'
+    # Specify an agency name.
+    agency = 'your agency'
+    # Specify the logging configuration information.
+    logstatus = Logging(targetBucket=targetBucket, targetPrefix=targetPrefix, grantList=grantList, agency=agency)
+    bucketName = "examplebucket"
+    # Configure logging for the bucket.
+    resp = obsClient.setBucketLogging(bucketName=bucketName , logstatus=logstatus )
+
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Set Bucket Logging Succeeded')
+        print('requestId:', resp.requestId)
+    else:
+        print('Set Bucket Logging Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Set Bucket Logging Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0817.html b/docs/obs_3rd_party/python_sdk/obs_22_0817.html new file mode 100644 index 000000000..b525e92fd --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0817.html @@ -0,0 +1,532 @@ + + +

Obtaining the Logging Configuration of a Bucket (SDK for Python)

+

Function

This API returns the logging configuration of a bucket.

+
+

Restrictions

+
+

Method

ObsClient.getBucketLogging(bucketName, extensionHeaders)

+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + +

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + +

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + +

GetResult.body Type

+

Description

+

Logging

+

Explanation:

+

Logging configuration information

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 Logging

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

targetBucket

+

str

+

No if used as a request parameter

+

Explanation:

+

Name of the bucket for storing log files

+

Restrictions:

+
  • This bucket must be in the same region as the bucket with logging enabled.
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

targetPrefix

+

str

+

No if used as a request parameter

+

Explanation:

+

Name prefix for log files stored in the log storage bucket

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

targetGrants

+

list of Grant

+

No if used as a request parameter

+

Explanation:

+

Permission information list of grantees, which defines grantees and their permissions for log files. For details, see Table 3.

+

Default value:

+

None

+

agency

+

str

+

Yes if the parameter is in a request to enable bucket logging

+

Explanation:

+

Name of the IAM agency created by the owner of the target bucket for OBS.

+

You can select an existing IAM agency or create one.

+

Restrictions:

+

By default, the IAM agency only requires the PutObject permission to upload logs to the target bucket. If default encryption is enabled for the target bucket, the agency also requires the KMS Administrator permission in the region where the target bucket is located.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 3 Grant

Parameter

+

Type

+

Description

+

grantee

+

Grantee

+

Explanation:

+

Grantee information. For details, see Table 4.

+

Default value:

+

None

+

permission

+

str

+

Explanation:

+

Granted permission

+

Value range:

+

See Table 6.

+

Default value:

+

None

+

delivered

+

bool

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket

+

Value range:

+

True: The bucket ACL is applied to all objects in the bucket.

+

False: The bucket ACL is not applied to all objects in the bucket.

+

Default value:

+

False

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 4 Grantee

Parameter

+

Type

+

Description

+

grantee_id

+

str

+

Explanation:

+

Account (domain) ID of the grantee.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and IAM User ID? (SDK for Python)

+

Default value:

+

None

+

grantee_name

+

str

+

Explanation:

+

Account name of the grantee.

+

Restrictions:

+
  • Starts with a letter. Contains 6 to 32 characters.
  • Contains only letters, digits, hyphens (-), and underscores (_).
+

Default value:

+

None

+

group

+

str

+

Explanation:

+

Authorized user group. For details, see Table 5.

+

Default value:

+

None

+
+
+

The authorized entity can be an individual user or a user group. grantee_id and grantee_name must be used together and they cannot be used with group.

+
+
+ +
+ + + + + + + + + + + + + +
Table 5 Group

Constant

+

Description

+

ALL_USERS

+

All users

+

AUTHENTICATED_USERS

+

Authorized users. This constant is deprecated.

+

LOG_DELIVERY

+

Log delivery group. This constant is deprecated.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
Table 6 Permission

Constant

+

Description

+

READ

+

Read permission

+

A grantee with this permission for a bucket can obtain the list of objects, multipart uploads, bucket metadata, and object versions in the bucket.

+

A grantee with this permission for an object can obtain the object content and metadata.

+

WRITE

+

Write permission

+

A grantee with this permission for a bucket can upload, overwrite, and delete any object or part in the bucket.

+

Such permission for an object is not applicable.

+

READ_ACP

+

Permission to read ACL configurations

+

A grantee with this permission can obtain the ACL of a bucket or object.

+

A bucket or object owner has this permission for the bucket or object permanently.

+

WRITE_ACP

+

Permission to modify ACL configurations

+

A grantee with this permission can update the ACL of a bucket or object.

+

A bucket or object owner has this permission for the bucket or object permanently.

+

A grantee with this permission can modify the access control policy and thus the grantee obtains full access permissions.

+

FULL_CONTROL

+

Full control access, including read and write permissions for a bucket and its ACL, or for an object and its ACL.

+

A grantee with this permission for a bucket has READ, WRITE, READ_ACP, and WRITE_ACP permissions for the bucket.

+

A grantee with this permission for an object has READ, READ_ACP, and WRITE_ACP permissions for the object.

+
+
+

Code Examples

This example returns the logging configuration of bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName="examplebucket"
+    # Obtain the logging configuration of the bucket.
+    resp = obsClient.getBucketLogging(bucketName)
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Get Bucket Logging Succeeded')
+        print('requestId:', resp.requestId)
+        print('targetBucket:', resp.body.targetBucket)
+        print('targetPrefix:', resp.body.targetPrefix)
+
+        index = 1
+        for grant in resp.body.targetGrants:
+            print('grant [' + str(index) + ']')
+            print('grant_id:', grant.grantee.grantee_id)
+            print('grant_name:', grant.grantee.grantee_name)
+            print('group:', grant.grantee.group)
+            print('permission:', grant.permission)
+            index += 1
+    else:
+        print('Get Bucket Logging Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Get Bucket Logging Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0818.html b/docs/obs_3rd_party/python_sdk/obs_22_0818.html new file mode 100644 index 000000000..53ecfd51c --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0818.html @@ -0,0 +1,278 @@ + + +

Configuring a Bucket Policy (SDK for Python)

+

Function

OBS provides access control over buckets. You can use an access policy to define whether a user can perform certain operations on a specific bucket. OBS access control can be implemented using IAM permissions, bucket policies, and ACLs.

+

A bucket policy is applied to a configured bucket and the objects in it. You can use a bucket policy to grant permissions for the bucket and the objects in it to IAM users or other accounts. If you want IAM users to have different permissions for different buckets, you can configure required bucket policies.

+

This API configures a policy for a bucket.

+
+

Restrictions

+
+

Method

ObsClient.setBucketPolicy(bucketName, policyJSON, extensionHeaders)

+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + +

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

policyJSON

+

str

+

Yes

+

Explanation:

+

Policy information in JSON format.

+

Restrictions:

+
  • The bucket name contained in the Resource parameter of the policy must be the one specified for the current bucket policy.
+

Default value:

+

None

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + +

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+
+

Code Examples

This example configures a policy for bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName = "examplebucket"
+    # Specify the bucket policy. The following example policy grants all operation permissions on examplebucket (including the bucket and its objects) to user xxx (user ID) under tenant xxx (domain ID).
+    policyJSON = '{"Statement":[{"Sid":"ExampleStatementID1","Effect":"Allow","Principal":{"ID":["domain/**********:user/**********"]},"Action":["*"],"Resource":["examplebucket/*","examplebucket"]}]}'
+    # Configure the bucket policy.
+    resp = obsClient.setBucketPolicy(bucketName, policyJSON)
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Set Bucket Policy Succeeded')
+        print('requestId:', resp.requestId)
+    else:
+        print('Set Bucket Policy Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Set Bucket Policy Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0819.html b/docs/obs_3rd_party/python_sdk/obs_22_0819.html new file mode 100644 index 000000000..a7ae816ad --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0819.html @@ -0,0 +1,303 @@ + + +

Obtaining the Policy of a Bucket (SDK for Python)

+

Function

OBS provides access control over buckets. You can use an access policy to define whether a user can perform certain operations on a specific bucket. OBS access control can be implemented using IAM permissions, bucket policies, and ACLs.

+

A bucket policy is applied to a configured bucket and the objects in it. You can use a bucket policy to grant permissions for the bucket and the objects in it to IAM users or other accounts. If you want IAM users to have different permissions for different buckets, you can configure required bucket policies.

+

This API returns the policy of a bucket.

+
+

Restrictions

+
+

Method

ObsClient.getBucketPolicy(bucketName, extensionHeaders)

+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + +

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + +

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + +

GetResult.body Type

+

Description

+

Policy

+

Explanation:

+

Bucket policy

+
+
+ +
+ + + + + + + + + +
Table 2 Policy

Parameter

+

Type

+

Description

+

policyJSON

+

str

+

Explanation:

+

Policy information in JSON format

+

Restrictions:

+
  • The bucket name contained in the Resource parameter of the policy must be the one specified for the current bucket policy.
+

Default value:

+

None

+
+
+
+

Code Examples

This example returns the policy of bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName="examplebucket"
+    # Obtain the bucket policy.
+    resp = obsClient.getBucketPolicy(bucketName)
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Get Bucket Policy Succeeded')
+        print('requestId:', resp.requestId)
+        print('policyJSON:', resp.body.policyJSON)
+    else:
+        print('Get Bucket Policy Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Get Bucket Policy Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0820.html b/docs/obs_3rd_party/python_sdk/obs_22_0820.html new file mode 100644 index 000000000..68d58ddf1 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0820.html @@ -0,0 +1,260 @@ + + +

Deleting a Bucket Policy (SDK for Python)

+

Function

OBS provides access control over buckets. You can use an access policy to define whether a user can perform certain operations on a specific bucket. OBS access control can be implemented using IAM permissions, bucket policies, and ACLs.

+

A bucket policy is applied to a configured bucket and the objects in it. You can use a bucket policy to grant permissions for the bucket and the objects in it to IAM users or other accounts. If you want IAM users to have different permissions for different buckets, you can configure required bucket policies.

+

This API deletes the policy of a bucket. OBS returns 204 No Content if the deletion is successful or the requested bucket policy does not exist.

+
+

Restrictions

+
+

Method

ObsClient.deleteBucketPolicy(bucketName, extensionHeaders)

+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + +

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + +

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+
+

Code Examples

This example deletes the policy of bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName="examplebucket"
+    # Delete the bucket policy.
+    resp = obsClient.deleteBucketPolicy(bucketName)
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Delete Bucket Policy Succeeded')
+        print('requestId:', resp.requestId)
+    else:
+        print('Delete Bucket Policy Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Delete Bucket Policy Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0821.html b/docs/obs_3rd_party/python_sdk/obs_22_0821.html new file mode 100644 index 000000000..b5ada0039 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0821.html @@ -0,0 +1,734 @@ + + +

Configuring Lifecycle Rules for a Bucket (SDK for Python)

+

Function

You can configure lifecycle rules to periodically delete objects or transition objects between storage classes.

+

This API configures lifecycle rules for a bucket.

+
  • Expired objects will be permanently deleted and cannot be recovered.
  • Multi-AZ redundancy is not available for Cold storage. For this reason, buckets or objects with multi-AZ redundancy cannot be transitioned to the Cold storage class based on a lifecycle rule.
  • The minimum storage duration is 30 days for Warm storage, and 90 days for Cold storage. After an object is transitioned to the Cold storage class, if it stays in this storage class for less than 90 days, you still need to pay for a full 90 days.
+
+
+

Restrictions

+
+

Method

ObsClient.setBucketLifecycle(bucketName, lifecycle, extensionHeaders)

+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + +

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

lifecycle

+

Lifecycle

+

Yes

+

Explanation:

+

List of lifecycle rules. For details, see Table 1.

+

Default value:

+

None

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + +
Table 1 Lifecycle

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

rule

+

list of Rule

+

Yes

+

Explanation:

+

List of lifecycle rules. For details, see Table 2.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 Rule

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

id

+

str

+

No

+

Explanation:

+

Lifecycle rule ID

+

Value range:

+

The value must contain 1 to 255 characters.

+

Default value:

+

None

+

prefix

+

str

+

Yes

+

Explanation:

+

Object name prefix. It identifies the objects the rule applies to. You can leave this parameter blank to apply the rule to all objects in the bucket.

+

Assume that you have the following objects: logs/day1, logs/day2, logs/day3, and ExampleObject.jpg. If you set Prefix to ExampleObject.jpg, the rule applies to object ExampleObject.jpg only. If you set Prefix to logs/, the rule applies to the three objects with name starting with logs/. If you leave Prefix blank, the rule applies to all objects in the bucket.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

status

+

str

+

Yes

+

Explanation:

+

Whether the rule is enabled

+

Value range:

+
  • Enabled
  • Disabled
+

Default value:

+

None

+

transition

+

Transition

+

or

+

list of Transition

+

No

+

Explanation:

+

Policies for storage class transition, including transition time and the storage class after transition. For details, see Table 3.

+

Restrictions:

+

This parameter applies only to the current object version.

+

Default value:

+

None

+

expiration

+

Expiration

+

No

+

Explanation:

+

Object expiration time. For details, see Table 4.

+

Restrictions:

+

This parameter applies only to the current object version.

+

Default value:

+

None

+

noncurrentVersionTransition

+

NoncurrentVersionTransition

+

or

+

list of NoncurrentVersionTransition

+

No

+

Explanation:

+

Policies for storage class transition, including transition time and the storage class after transition. For details, see Table 7.

+

Restrictions:

+
  • This parameter applies only to noncurrent object versions.
  • Versioning is enabled (or suspended after being enabled) for the bucket.
  • This parameter is not available for parallel file systems.
+

Default value:

+

None

+

noncurrentVersionExpiration

+

NoncurrentVersionExpiration

+

No

+

Explanation:

+

Expiration time of noncurrent object versions. For details, see Table 8.

+

Restrictions:

+
  • This parameter applies only to noncurrent object versions.
  • Versioning is enabled (or suspended after being enabled) for the bucket.
+
CAUTION:

This parameter is not available for parallel file systems.

+
+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 3 Transition

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

storageClass

+

str

+

Yes if used as a request parameter

+

Explanation:

+

Storage class of the object after transition

+

Restrictions:

+
  • The Standard storage class is not supported.
  • Restrictions on storage class transitions:
    • Only transitions from the Standard storage class to the Warm storage class are supported. To transition objects from Warm to Standard, you must manually do it.
    • Only transitions from the Standard or Warm storage class to the Cold storage class are supported. To transition objects from Cold to Standard or Warm, you must restore the objects first and then manually transition their storage class.
    • Multi-AZ redundancy is not available for Cold storage. For this reason, buckets or objects with multi-AZ redundancy cannot be transitioned to the Cold storage class based on a lifecycle rule.
    +
+

Value range:

+

See Table 5.

+

Default value:

+

None

+

date

+

str

+

or

+

DateTime

+

Yes if the parameter is used as a request parameter and days is absent

+

Explanation:

+

OBS executes the lifecycle rule for objects that were modified before the specified date.

+

Restrictions:

+

The value must conform with the ISO8601 standards and indicate UTC 00:00. For example, 2018-01-01T00:00:00.000Z indicates only objects that were last modified before the specified time are transitioned to the specified storage class.

+

For example, DateTime(year=2023, month=9, day=12)

+

Default value:

+

None

+

days

+

int

+

Yes if the parameter is used as a request parameter and date is absent

+

Explanation:

+

Number of days (since the last update was made to the object) after which the lifecycle rule takes effect

+

Restrictions:

+

This parameter applies only to the current object version.

+

Value range:

+

An integer greater than or equal to 0, in days

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 4 Expiration

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

date

+

str

+

or

+

DateTime

+

Yes if the parameter is used as a request parameter and days is absent

+

Explanation:

+

OBS executes the lifecycle rule for objects that were modified before the specified date.

+

Restrictions:

+

The value must conform with the ISO8601 standards and indicate UTC 00:00. For example, 2018-01-01T00:00:00.000Z indicates only objects that were last modified before the specified time are deleted.

+

For example, DateTime(year=2023, month=9, day=12)

+

Default value:

+

None

+

days

+

int

+

Yes if the parameter is used as a request parameter and date is absent

+

Explanation:

+

Number of days (since the last update was made to the object) after which the lifecycle rule takes effect

+

Restrictions:

+

This parameter applies only to the current object version.

+

Value range:

+

An integer greater than or equal to 0, in days

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 5 StorageClass

Parameter

+

Type

+

Description

+

STANDARD

+

Standard storage class

+

Explanation:

+

Features low access latency and high throughput and is used for storing massive, frequently accessed (multiple times a month) or small objects (< 1 MB) requiring quick response.

+

WARM

+

Warm storage class

+

Explanation:

+

Used for storing data that is semi-frequently accessed (fewer than 12 times a year) but is instantly available when needed.

+

COLD

+

Cold storage class

+

Explanation:

+

Used for storing rarely accessed (once a year) data.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 6 DateTime

Parameter

+

Type

+

Description

+

year

+

int

+

Explanation:

+

Year in UTC

+

Default value:

+

None

+

month

+

int

+

Explanation:

+

Month in UTC

+

Default value:

+

None

+

day

+

int

+

Explanation:

+

Day in UTC

+

Default value:

+

None

+

hour

+

int

+

Explanation:

+

Hour in UTC

+

Restrictions:

+

The value is in 24-hour format.

+

Default value:

+

0

+

min

+

int

+

Explanation:

+

Minute in UTC

+

Default value:

+

0

+

sec

+

int

+

Explanation:

+

Second in UTC

+

Default value:

+

0

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 7 NoncurrentVersionTransition

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

storageClass

+

str

+

Yes if used as a request parameter

+

Explanation:

+

Storage class of noncurrent object versions after transition

+

Restrictions:

+
  • The Standard storage class is not supported.
  • Restrictions on storage class transitions:
    • Only transitions from the Standard storage class to the Warm storage class are supported. To transition objects from Warm to Standard, you must manually do it.
    • Only transitions from the Standard or Warm storage class to the Cold storage class are supported. To transition objects from Cold to Standard or Warm, you must restore the objects first and then manually transition their storage class.
    • Multi-AZ redundancy is not available for Cold storage. For this reason, buckets or objects with multi-AZ redundancy cannot be transitioned to the Cold storage class based on a lifecycle rule.
    +
+

Value range:

+

See Table 5.

+

Default value:

+

None

+

noncurrentDays

+

int

+

Yes if used as a request parameter

+

Explanation:

+

Number of days an object is noncurrent before the specified rule takes effect

+

Restrictions:

+

This parameter applies only to noncurrent object versions.

+

Value range:

+

An integer greater than or equal to 0, in days

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + +
Table 8 NoncurrentVersionExpiration

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

noncurrentDays

+

int

+

Yes if used as a request parameter

+

Explanation:

+

Number of days an object is noncurrent before the specified rule takes effect

+

Restrictions:

+

This parameter applies only to noncurrent object versions.

+

Value range:

+

An integer greater than or equal to 0, in days

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + +

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 9 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+
+

Code Examples

This example configures a lifecycle rule for bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
from obs import ObsClient
+from obs import Expiration, NoncurrentVersionExpiration
+from obs import DateTime
+from obs import Rule
+from obs import Lifecycle
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    # Configure a lifecycle rule for deleting objects with prefix1 as the prefix after 60 days since the last update.
+    rule1 = Rule(id='rule1', prefix='prefix1', status='Enabled', expiration=Expiration(days=60))
+    # Configure a lifecycle rule for deleting objects with prefix2 as the prefix on December 31, 2023.
+    rule2 = Rule(id='rule2', prefix='prefix2', status='Enabled', expiration=Expiration(date=DateTime(2023, 12, 31)))
+    lifecycle = Lifecycle(rule=[rule1, rule2])
+    bucketName="examplebucket"
+    # Configures the lifecycle rules for the bucket.
+    resp = obsClient.setBucketLifecycle(bucketName, lifecycle)
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Set Bucket Lifecycle Succeeded')
+        print('requestId:', resp.requestId)
+    else:
+        print('Set Bucket Lifecycle Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Set Bucket Lifecycle Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0822.html b/docs/obs_3rd_party/python_sdk/obs_22_0822.html new file mode 100644 index 000000000..bcfedc22a --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0822.html @@ -0,0 +1,764 @@ + + +

Obtaining the Lifecycle Configuration of a Bucket (SDK for Python)

+

Function

You can configure lifecycle rules to periodically delete objects or transition objects between storage classes.

+

This API returns the lifecycle rules of a bucket.

+
+

Restrictions

+
+

Method

ObsClient.getBucketLifecycle(bucketName, extensionHeaders)

+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + +

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + +

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + +

GetResult.body Type

+

Description

+

LifecycleResponse

+

Explanation:

+

Response to the request for obtaining the lifecycle configuration information of a bucket

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + +
Table 2 LifecycleResponse

Parameter

+

Type

+

Description

+

lifecycleConfig

+

Lifecycle

+

Explanation:

+

Bucket lifecycle configuration. For details, see Table 3.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + +
Table 3 Lifecycle

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

rule

+

list of Rule

+

Yes if used as a request parameter

+

Explanation:

+

List of lifecycle rules. For details, see Table 4.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 4 Rule

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

id

+

str

+

No if used as a request parameter

+

Explanation:

+

Lifecycle rule ID

+

Value range:

+

The value must contain 1 to 255 characters.

+

Default value:

+

None

+

prefix

+

str

+

Yes if used as a request parameter

+

Explanation:

+

Object name prefix. It identifies the objects the rule applies to. You can leave this parameter blank to apply the rule to all objects in the bucket.

+

Assume that you have the following objects: logs/day1, logs/day2, logs/day3, and ExampleObject.jpg. If you set Prefix to ExampleObject.jpg, the rule applies to object ExampleObject.jpg only. If you set Prefix to logs/, the rule applies to the three objects with name starting with logs/. If you leave Prefix blank, the rule applies to all objects in the bucket.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

status

+

str

+

Yes if used as a request parameter

+

Explanation:

+

Whether the rule is enabled

+

Value range:

+
  • Enabled
  • Disabled
+

Default value:

+

None

+

transition

+

Transition

+

or

+

list of Transition

+

No if used as a request parameter

+

Explanation:

+

Policies for storage class transition, including transition time and the storage class after transition. For details, see Table 5.

+

Restrictions:

+

This parameter applies only to the current object version.

+

Default value:

+

None

+

expiration

+

Expiration

+

No if used as a request parameter

+

Explanation:

+

Object expiration time. For details, see Table 7.

+

Restrictions:

+

This parameter applies only to the current object version.

+

Default value:

+

None

+

noncurrentVersionTransition

+

NoncurrentVersionTransition

+

or

+

list of NoncurrentVersionTransition

+

No if used as a request parameter

+

Explanation:

+

Policies for storage class transition, including transition time and the storage class after transition. For details, see Table 9.

+

Restrictions:

+
  • This parameter applies only to noncurrent object versions.
  • Versioning is enabled (or suspended after being enabled) for the bucket.
  • This parameter is not available for parallel file systems.
+

Default value:

+

None

+

noncurrentVersionExpiration

+

NoncurrentVersionExpiration

+

No if used as a request parameter

+

Explanation:

+

Expiration time of noncurrent object versions. For details, see Table 10.

+

Restrictions:

+
  • This parameter applies only to noncurrent object versions.
  • Versioning is enabled (or suspended after being enabled) for the bucket.
  • This parameter is not available for parallel file systems.
+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 5 Transition

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

storageClass

+

str

+

Yes if used as a request parameter

+

Explanation:

+

Storage class of the object after transition

+

Restrictions:

+
  • The Standard storage class is not supported.
  • Restrictions on storage class transitions:
    • Only transitions from the Standard storage class to the Warm storage class are supported. To transition objects from Warm to Standard, you must manually do it.
    • Only transitions from the Standard or Warm storage class to the Cold storage class are supported. To transition objects from Cold to Standard or Warm, you must restore the objects first and then manually transition their storage class.
    • Multi-AZ redundancy is not available for Cold storage. For this reason, buckets or objects with multi-AZ redundancy cannot be transitioned to the Cold storage class based on a lifecycle rule.
    +
+

Value range:

+

See Table 6.

+

Default value:

+

None

+

date

+

str

+

or

+

DateTime

+

Yes if the parameter is used as a request parameter and days is absent

+

Explanation:

+

Date when an object will be transitioned.

+

Restrictions:

+

The value must conform with the ISO8601 standards and indicate UTC 00:00. For example, 2018-01-01T00:00:00.000Z indicates only objects that were last modified before the specified time are transitioned to the specified storage class.

+

For example, DateTime(year=2023, month=9, day=12)

+

Default value:

+

None

+

days

+

int

+

Yes if the parameter is used as a request parameter and date is absent

+

Explanation:

+

Number of days (since the last update was made to the object) after which the lifecycle rule takes effect

+

Restrictions:

+

This parameter applies only to the current object version.

+

Value range:

+

An integer greater than or equal to 0, in days

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 6 StorageClass

Parameter

+

Type

+

Description

+

STANDARD

+

Standard storage class

+

Explanation:

+

Features low access latency and high throughput and is used for storing massive, frequently accessed (multiple times a month) or small objects (< 1 MB) requiring quick response.

+

WARM

+

Warm storage class

+

Explanation:

+

Used for storing data that is semi-frequently accessed (fewer than 12 times a year) but is instantly available when needed.

+

COLD

+

Cold storage class

+

Explanation:

+

Used for storing rarely accessed (once a year) data.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 7 Expiration

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

date

+

str

+

or

+

DateTime

+

Yes if the parameter is used as a request parameter and days is absent

+

Explanation:

+

OBS executes the lifecycle rule for objects that were modified before the specified date.

+

Restrictions:

+

The value must conform with the ISO8601 standards and indicate UTC 00:00. For example, 2018-01-01T00:00:00.000Z indicates only objects that were last modified before the specified time are deleted.

+

For example, DateTime(year=2023, month=9, day=12)

+

Default value:

+

None

+

days

+

int

+

Yes if the parameter is used as a request parameter and date is absent

+

Explanation:

+

Number of days (since the last update was made to the object) after which the lifecycle rule takes effect

+

Restrictions:

+

This parameter applies only to the current object version.

+

Value range:

+

An integer greater than or equal to 0, in days

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 8 DateTime

Parameter

+

Type

+

Description

+

year

+

int

+

Explanation:

+

Year in UTC

+

Default value:

+

None

+

month

+

int

+

Explanation:

+

Month in UTC

+

Default value:

+

None

+

day

+

int

+

Explanation:

+

Day in UTC

+

Default value:

+

None

+

hour

+

int

+

Explanation:

+

Hour in UTC

+

Restrictions:

+

The value is in 24-hour format.

+

Default value:

+

0

+

min

+

int

+

Explanation:

+

Minute in UTC

+

Default value:

+

0

+

sec

+

int

+

Explanation:

+

Second in UTC

+

Default value:

+

0

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 9 NoncurrentVersionTransition

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

storageClass

+

str

+

Yes if used as a request parameter

+

Explanation:

+

Storage class of the object after transition

+

Restrictions:

+
  • The Standard storage class is not supported.
  • Restrictions on storage class transitions:
    • Only transitions from the Standard storage class to the Warm storage class are supported. To transition objects from Warm to Standard, you must manually do it.
    • Only transitions from the Standard or Warm storage class to the Cold storage class are supported. To transition objects from Cold to Standard or Warm, you must restore the objects first and then manually transition their storage class.
    • Multi-AZ redundancy is not available for Cold storage. For this reason, buckets or objects with multi-AZ redundancy cannot be transitioned to the Cold storage class based on a lifecycle rule.
    +
+

Value range:

+

See Table 6.

+

Default value:

+

None

+

noncurrentDays

+

int

+

Yes if used as a request parameter

+

Explanation:

+

Number of days an object is noncurrent before the specified rule takes effect

+

Restrictions:

+

This parameter applies only to noncurrent object versions.

+

Value range:

+

An integer greater than or equal to 0, in days

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + +
Table 10 NoncurrentVersionExpiration

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

noncurrentDays

+

int

+

Yes if used as a request parameter

+

Explanation:

+

Number of days an object is noncurrent before the specified rule takes effect

+

Restrictions:

+

This parameter applies only to noncurrent object versions.

+

Value range:

+

An integer greater than or equal to 0, in days

+

Default value:

+

None

+
+
+
+

Code Examples

This example returns the lifecycle configuration of bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName="examplebucket"
+    # Obtain the lifecycle configuration of the bucket.
+    resp = obsClient.getBucketLifecycle(bucketName)
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Get Bucket Lifecycle Succeeded')
+        print('requestId:', resp.requestId)
+        index = 1
+        for rule in resp.body.lifecycleConfig.rule:
+            print('rule [' + str(index) + ']')
+            print('id:', rule.id)
+            print('prefix:', rule.prefix)
+            print('status:', rule.status)
+            if rule.expiration:
+                print('days:', rule.expiration.days)
+                print('date:', rule.expiration.date)
+            if rule.noncurrentVersionExpiration:
+                print('noncurrentDays:', rule.noncurrentVersionExpiration.noncurrentDays)
+        index += 1
+    else:
+        print('Get Bucket Lifecycle Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Get Bucket Lifecycle Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0823.html b/docs/obs_3rd_party/python_sdk/obs_22_0823.html new file mode 100644 index 000000000..b27a7faa6 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0823.html @@ -0,0 +1,259 @@ + + +

Deleting the Lifecycle Configuration of a Bucket (SDK for Python)

+

Function

You can configure lifecycle rules to periodically delete objects or transition objects between storage classes.

+

This API deletes the lifecycle configuration of a bucket.

+
+

Restrictions

+
+

Method

ObsClient.deleteBucketLifecycle(bucketName, extensionHeaders)

+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + +

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + +

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+
+

Code Examples

This example deletes all lifecycle configurations of bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName="examplebucket"
+    # Delete lifecycle configurations of the bucket.
+    resp = obsClient.deleteBucketLifecycle(bucketName)
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Delete Bucket Lifecycle Succeeded')
+        print('requestId:', resp.requestId)
+    else:
+        print('Delete Bucket Lifecycle Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Delete Bucket Lifecycle Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0824.html b/docs/obs_3rd_party/python_sdk/obs_22_0824.html new file mode 100644 index 000000000..df80b5b0a --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0824.html @@ -0,0 +1,638 @@ + + +

Configuring Static Website Hosting for a Bucket (SDK for Python)

+

Function

You can host static website resources such as HTML web pages, flash files, or audio and video files in an OBS bucket, so that you can provide these hosted resources using the bucket's website endpoint to end users. Typical use cases include:

+ +

This API configures static website hosting for a bucket.

+
+

Restrictions

+
+

Method

ObsClient.setBucketWebsite(bucketName, website, extensionHeaders)

+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + +

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

website

+

WebsiteConfiguration

+

Yes

+

Explanation:

+

Input parameters for configuring static website hosting. For details, see Table 1.

+

Default value:

+

None

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 WebsiteConfiguration

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

redirectAllRequestTo

+

RedirectAllRequestTo

+

No if used as a request parameter

+

Explanation:

+

Redirection rules for all requests. For details, see Table 2.

+

Default value:

+

None

+

indexDocument

+

IndexDocument

+

No if used as a request parameter

+

Explanation:

+

Default page configuration. For details, see Table 3.

+

Default value:

+

None

+

errorDocument

+

ErrorDocument

+

No if used as a request parameter

+

Explanation:

+

Error page configuration. For details, see Table 4.

+

Default value:

+

None

+

routingRules

+

list of RoutingRule

+

No if used as a request parameter

+

Explanation:

+

List of routing rules. For details, see Table 5.

+

Default value:

+

None

+
+
+
  • errorDocument, indexDocument, and routingRules must be used together and they cannot be used with redirectAllRequestsTo.
  • When errorDocument, indexDocument, and routingRules are used together, routingRules can be left blank.
  • You must specify either the combo of fields ErrorDocument, IndexDocument, and RoutingRules, or the RedirectAllRequestsTo field.
+
+ +
+ + + + + + + + + + + + + + + + +
Table 2 RedirectAllRequestTo

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

hostName

+

str

+

Yes if used as a request parameter

+

Explanation:

+

Host name used for redirection, for example, www.example.com

+

Restrictions:

+

The host name must comply with the host name rules.

+

Default value:

+

None

+

protocol

+

str

+

No if used as a request parameter

+

Explanation:

+

Protocol used for redirection

+

Value range:

+
  • http
  • https
+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + +
Table 3 IndexDocument

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

suffix

+

str

+

Yes if used as a request parameter

+

Explanation:

+

Suffix that is appended to the request for a directory. For example, if the suffix is index.html and you request samplebucket/images/, the returned data will be for the object named images/index.html in the bucket samplebucket.

+

Value range:

+

This parameter can neither be left blank nor contain slashes (/).

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + +
Table 4 ErrorDocument

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

key

+

str

+

No if used as a request parameter

+

Explanation:

+

Object name to use when a 4XX error occurs. This parameter specifies the webpage to display when an error occurs.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 5 RoutingRule

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

condition

+

Condition

+

No if used as a request parameter

+

Explanation:

+

Conditions that must be met for the specified redirect to apply

+

Value range:

+

See Table 6.

+

Default value:

+

None

+

redirect

+

Redirect

+

Yes if used as a request parameter

+

Explanation:

+

Details about the redirection. For details, see Table 7.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 6 Condition

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

keyPrefixEquals

+

str

+

No if used as a request parameter

+

Explanation:

+

Object name prefix for the redirection to take effect. If the name prefix of the requested object is the same as the value specified for this parameter, the redirection rule takes effect.

+

For example, to redirect the requests for the object ExamplePage.html, set KeyPrefixEquals to ExamplePage.html.

+

Restrictions:

+

This parameter cannot be used together with httpErrorCodeReturnedEquals.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

httpErrorCodeReturnedEquals

+

int

+

No if used as a request parameter

+

Explanation:

+

HTTP error code for the redirection to take effect. If there is an error, and the error code returned is the same as the value specified for this parameter, the redirection rule takes effect.

+

For example, if you want to redirect requests to NotFound.html when HTTP error code 404 is returned, set httpErrorCodeReturnedEquals to 404 in Condition, and set ReplaceKeyWith to NotFound.html in Redirect.

+

Restrictions:

+

This parameter cannot be used together with keyPrefixEquals.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 7 Redirect

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

protocol

+

str

+

No if used as a request parameter

+

Explanation:

+

Protocol used for redirection

+

Value range:

+
  • http
  • https
+

Default value:

+

None

+

hostName

+

str

+

No if used as a request parameter

+

Explanation:

+

Host name used for redirection

+

Default value:

+

None

+

replaceKeyPrefixWith

+

str

+

No if used as a request parameter

+

Explanation:

+

Object name prefix used in the redirection request

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

replaceKeyWith

+

str

+

No if used as a request parameter

+

Explanation:

+

Object name used in the redirection request

+

Restrictions:

+

This parameter cannot be used together with replaceKeyPrefixWith.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

httpRedirectCode

+

int

+

No if used as a request parameter

+

Explanation:

+

HTTP status code in the response to the redirect request.

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + +

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 8 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+
+

Code Examples

This example configures static website hosting for bucket examplebucket.
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
from obs import ObsClient
+from obs import WebsiteConfiguration
+from obs import IndexDocument
+from obs import ErrorDocument
+from obs import RoutingRule
+from obs import Condition
+from obs import Redirect
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    # Specify an error page when a 4XX error occurs.
+    errorDocument = ErrorDocument(key='error.html')
+    # Specify a default page.
+    indexDocument = IndexDocument(suffix='index.html')
+    # Specify a rule for redirecting requests to NotFound.html if the status code is 404.
+    routingRule1 = RoutingRule(condition=Condition(httpErrorCodeReturnedEquals=404),
+                               redirect=Redirect(protocol='http', replaceKeyWith='NotFound.html'))
+    # Configure the redirection rules in list format. Multiple rules can be configured.
+    routingRules = [routingRule1]
+    bucketName = "examplebucket"
+    # Configure static website hosting for the bucket.
+    resp = obsClient.setBucketWebsite(bucketName,
+                                      WebsiteConfiguration(errorDocument=errorDocument, indexDocument=indexDocument,
+                                                           routingRules=routingRules))
+
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Set Bucket Website Succeeded')
+        print('requestId:', resp.requestId)
+    else:
+        print('Set Bucket Website Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Set Bucket Website Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0825.html b/docs/obs_3rd_party/python_sdk/obs_22_0825.html new file mode 100644 index 000000000..6c5d4f866 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0825.html @@ -0,0 +1,634 @@ + + +

Obtaining Static Website Hosting for a Bucket (SDK for Python)

+

Function

You can host static website resources such as HTML web pages, flash files, as well as audio and video files in an OBS bucket, so that you can provide these hosted resources using the bucket's website endpoint to end users. Typical use cases include:

+ +

This API returns the static website hosting configuration of the bucket.

+
+

Restrictions

+
+

Method

ObsClient.getBucketWebsite(bucketName, extensionHeaders)

+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + +

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + +

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + +

GetResult.body Type

+

Description

+

WebsiteConfiguration

+

Explanation:

+

Website hosting settings of a bucket

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 WebsiteConfiguration

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

redirectAllRequestTo

+

RedirectAllRequestTo

+

No if used as a request parameter

+

Explanation:

+

Redirection rules for all requests. For details, see Table 3.

+

indexDocument

+

IndexDocument

+

No if used as a request parameter

+

Explanation:

+

Default page configuration. For details, see Table 4.

+

errorDocument

+

ErrorDocument

+

No if used as a request parameter

+

Explanation:

+

Error page configuration. For details, see Table 5.

+

routingRules

+

list of RoutingRule

+

No if used as a request parameter

+

Explanation:

+

List of routing rules. For details, see Table 6.

+
+
+
  • errorDocument, indexDocument, and routingRules must be used together and they cannot be used with redirectAllRequestsTo.
  • When errorDocument, indexDocument, and routingRules are used together, routingRules can be left blank.
  • You must specify either the combo of fields ErrorDocument, IndexDocument, and RoutingRules, or the RedirectAllRequestsTo field.
+
+ +
+ + + + + + + + + + + + + + + + +
Table 3 RedirectAllRequestTo

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

hostName

+

str

+

Yes if used as a request parameter

+

Explanation:

+

Host name used for redirection, for example, www.example.com

+

Restrictions:

+

The host name must comply with the host name rules.

+

Default value:

+

None

+

protocol

+

str

+

No if used as a request parameter

+

Explanation:

+

Protocol used for redirection

+

Value range:

+
  • http
  • https
+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + +
Table 4 IndexDocument

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

suffix

+

str

+

Yes if used as a request parameter

+

Explanation:

+

Suffix that is appended to the request for a directory. For example, if the suffix is index.html and you request samplebucket/images/, the returned data will be for the object named images/index.html in the bucket samplebucket.

+

Value range:

+

This parameter can neither be left blank nor contain slashes (/).

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + +
Table 5 ErrorDocument

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

key

+

str

+

No if used as a request parameter

+

Explanation:

+

Object name to use when a 4XX error occurs. This parameter specifies the webpage to display when an error occurs.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 6 RoutingRule

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

condition

+

Condition

+

No if used as a request parameter

+

Explanation:

+

Conditions that must be met for the specified redirect to apply

+

Value range:

+

See Table 7.

+

Default value:

+

None

+

redirect

+

Redirect

+

Yes if used as a request parameter

+

Explanation:

+

Details about the redirection. For details, see Table 8.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 7 Condition

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

keyPrefixEquals

+

str

+

No if used as a request parameter

+

Explanation:

+

Object name prefix for the redirection to take effect. If the name prefix of the requested object is the same as the value specified for this parameter, the redirection rule takes effect.

+

For example, to redirect the requests for the object ExamplePage.html, set KeyPrefixEquals to ExamplePage.html.

+

Restrictions:

+

This parameter cannot be used together with httpErrorCodeReturnedEquals.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

httpErrorCodeReturnedEquals

+

int

+

No if used as a request parameter

+

Explanation:

+

HTTP error code for the redirection to take effect. If there is an error, and the error code returned is the same as the value specified for this parameter, the redirection rule takes effect.

+

For example, if you want to redirect requests to NotFound.html when HTTP error code 404 is returned, set httpErrorCodeReturnedEquals to 404 in Condition, and set ReplaceKeyWith to NotFound.html in Redirect.

+

Restrictions:

+

This parameter cannot be used together with keyPrefixEquals.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 8 Redirect

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

protocol

+

str

+

No if used as a request parameter

+

Explanation:

+

Protocol used for redirection

+

Value range:

+
  • http
  • https
+

Default value:

+

None

+

hostName

+

str

+

No if used as a request parameter

+

Explanation:

+

Host name used for redirection

+

Default value:

+

None

+

replaceKeyPrefixWith

+

str

+

No if used as a request parameter

+

Explanation:

+

Object name prefix used in the redirection request

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

replaceKeyWith

+

str

+

No if used as a request parameter

+

Explanation:

+

Object name used in the redirection request

+

Restrictions:

+

This parameter cannot be used together with replaceKeyPrefixWith.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

httpRedirectCode

+

int

+

No if used as a request parameter

+

Explanation:

+

HTTP status code in the response to the redirect request.

+

Default value:

+

None

+
+
+
+

Code Examples

This example returns the static website hosting configuration of bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName="examplebucket"
+    # Obtain the website configuration of the bucket.
+    resp = obsClient.getBucketWebsite(bucketName)
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Get Bucket Website Succeeded')
+        print('requestId:', resp.requestId)
+        if resp.body.redirectAllRequestTo:
+            print('redirectAllRequestTo.hostName:', resp.body.redirectAllRequestTo.hostName,
+                  ',redirectAllRequestTo.protocol:', resp.body.redirectAllRequestTo.protocol)
+        if resp.body.indexDocument:
+            print('indexDocument.suffix:', resp.body.indexDocument.suffix)
+        if resp.body.errorDocument:
+            print('errorDocument.key:', resp.body.errorDocument.key)
+        if resp.body.routingRules:
+            index = 1
+            for rout in resp.body.routingRules:
+                print('routingRule[', index, ']:')
+                index += 1
+                print('condition.keyPrefixEquals:', rout.condition.keyPrefixEquals,
+                      ',condition.httpErrorCodeReturnedEquals:', rout.condition.httpErrorCodeReturnedEquals)
+                print('redirect.protocol:', rout.redirect.protocol, ',redirect.hostName:', rout.redirect.hostName,
+                      ',redirect.replaceKeyPrefixWith:', rout.redirect.replaceKeyPrefixWith,
+                      ',redirect.replaceKeyWith:', rout.redirect.replaceKeyWith, ',redirect.httpRedirectCode:',
+                      rout.redirect.httpRedirectCode)
+    else:
+        print('Get Bucket Website Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Get Bucket Website Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0826.html b/docs/obs_3rd_party/python_sdk/obs_22_0826.html new file mode 100644 index 000000000..1d77a9bcc --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0826.html @@ -0,0 +1,262 @@ + + +

Deleting Static Website Hosting for a Bucket (SDK for Python)

+

Function

You can host static website resources such as HTML web pages, flash files, as well as audio and video files in an OBS bucket, so that you can provide these hosted resources using the bucket's website endpoint to end users. Typical use cases include:

+ +

This API deletes the static website hosting configuration of the bucket.

+
+

Restrictions

+
+

Method

ObsClient.deleteBucketWebsite(bucketName, extensionHeaders)

+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + +

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + +

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+
+

Code Examples

This example deletes the static website hosting configuration of bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName = "examplebucket"
+    # Delete the static website hosting configuration of the bucket.
+    resp = obsClient.deleteBucketWebsite(bucketName)
+
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Delete Bucket Website Succeeded')
+        print('requestId:', resp.requestId)
+    else:
+        print('Delete Bucket Website Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Delete Bucket Website Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0827.html b/docs/obs_3rd_party/python_sdk/obs_22_0827.html new file mode 100644 index 000000000..12541ea21 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0827.html @@ -0,0 +1,276 @@ + + +

Configuring Versioning for a Bucket (SDK for Python)

+

Function

You can enable versioning to automatically maintain previous versions of an object. When versioning is enabled, you can access earlier versions of an object to recover your data in the event of accidental actions or application failures.

+

This API configures the versioning status for a bucket.

+
+

Restrictions

+
+

Method

ObsClient.setBucketVersioning(bucketName, status, extensionHeaders)

+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + +

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

status

+

str

+

Yes

+

Explanation:

+

Versioning status of the bucket

+

Value range:

+

Versioning status of the bucket. Possible values are:

+
  • Enabled
  • Suspended
+

Default value:

+

None

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + +

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+
+

Code Examples

This example configures versioning for bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName = "examplebucket"
+    # Configure versioning for the bucket.
+    resp = obsClient.setBucketVersioning(bucketName, status='Enabled')
+
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Set Bucket Versioning Succeeded')
+        print('requestId:', resp.requestId)
+    else:
+        print('Set Bucket Versioning Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Set Bucket Versioning Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0828.html b/docs/obs_3rd_party/python_sdk/obs_22_0828.html new file mode 100644 index 000000000..16459e900 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0828.html @@ -0,0 +1,281 @@ + + +

Obtaining the Versioning Status of a Bucket (SDK for Python)

+

Function

You can enable versioning to automatically maintain previous versions of an object. When versioning is enabled, you can access earlier versions of an object to recover your data in the event of accidental actions or application failures.

+

This API obtains the versioning status of a bucket.

+
+

Restrictions

+
+

Method

ObsClient.getBucketVersioning(bucketName, extensionHeaders)

+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + +

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + +

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + +

GetResult.body Type

+

Description

+

str

+

Explanation:

+

Versioning status of the bucket

+
Value range:
  • Enabled
  • Suspended
+
+

Default value:

+

None

+
+
+
+

Code Examples

This example returns the versioning status of bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName="examplebucket"
+    # Obtain the bucket's versioning status.
+    resp = obsClient.getBucketVersioning(bucketName)
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Get Bucket Versioning Succeeded')
+        print('requestId:', resp.requestId)
+        print('status:', resp.body)
+    else:
+        print('Get Bucket Versioning Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Get Bucket Versioning Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0829.html b/docs/obs_3rd_party/python_sdk/obs_22_0829.html new file mode 100644 index 000000000..a78f96f32 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0829.html @@ -0,0 +1,396 @@ + + +

Configuring CORS for a Bucket (SDK for Python)

+

Function

Cross-origin resource sharing (CORS) is a mechanism defined by the World Wide Web Consortium (W3C) that allows a web application program in one domain to access resources located in another one. For general web page requests, website scripts and contents in one domain cannot interact with those in another because of Same Origin Policies (SOPs). OBS supports CORS rules that allow the resources in OBS to be requested by other domains.

+

This API configures CORS for a bucket.

+
+

Restrictions

+
+

Method

ObsClient.setBucketCors(bucketName, corsRuleList, extensionHeaders)

+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + +

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

corsRuleList

+

list of CorsRule

+

Yes

+

Explanation:

+

CORS rule list of the bucket. For details, see Table 1.

+

Restrictions:

+

A list can have a maximum of 100 CORS rules.

+

Default value:

+

None

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 CorsRule

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

id

+

str

+

No if used as a request parameter

+

Explanation:

+

CORS rule ID

+

Value range:

+

The value must contain 1 to 255 characters.

+

Default value:

+

None

+

allowedMethod

+

list of str

+

Yes if used as a request parameter

+

Explanation:

+

The allowed HTTP methods (types of operations on buckets and objects) for a cross-origin request.

+

Value range:

+

The following HTTP methods are supported:

+
  • GET
  • PUT
  • HEAD
  • POST
  • DELETE
+

Default value:

+

None

+

allowedOrigin

+

list of str

+

Yes if used as a request parameter

+

Explanation:

+

The origin from which the requests can access the bucket.

+

Restrictions:

+

Domain name of the origin. Each origin can contain only one wildcard character (*), for example, https://*.vbs.example.com.

+

Default value:

+

None

+

allowedHeader

+

list of str

+

No if used as a request parameter

+

Explanation:

+

The allowed headers for cross-origin requests. Only CORS requests matching the allowed headers are valid.

+

Restrictions:

+

Each header can contain at most one wildcard character (*). Spaces, ampersands (&), colons (:), less-than signs (<), and full-width characters are not allowed.

+

Default value:

+

None

+

maxAgeSecond

+

int

+

or

+

str

+

No if used as a request parameter

+

Explanation:

+

Time your client can cache the response for a cross-origin request

+

Restrictions:

+

Each CORS rule can contain at most one maxAgeSecond.

+

Value range:

+

An integer greater than or equal to 0, in seconds

+

Default value:

+

100

+

exposeHeader

+

list of str

+

No if used as a request parameter

+

Explanation:

+

The CORS-allowed additional headers in the response. These headers provide additional information to clients. By default, your browser can only access headers Content-Length and Content-Type. If your browser needs to access other headers, add them to a list of the allowed additional headers.

+

Restrictions:

+

Spaces, wildcard characters (*), ampersands (&), colons (:), and less-than signs (<) are not allowed.

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + +

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+
+

Code Examples

This example configures CORS rules for bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
from obs import ObsClient
+from obs import CorsRule
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    # Specify CORS rules.
+    cors1 = CorsRule(id='rule1', allowedMethod=['PUT', 'POST', 'GET', 'DELETE', 'HEAD'],
+                     allowedOrigin=['obs.hostname', 'obs.hostname1'], allowedHeader=['obs-header-1'],
+                     maxAgeSecond=60)
+    cors2 = CorsRule(id='rule2', allowedMethod=['PUT', 'POST', 'GET'],
+                     allowedOrigin=['obs.hostname', 'obs.hostname1'], allowedHeader=['header-1', 'header-2'],
+                     maxAgeSecond=50, exposeHeader=['head1'])
+    corsList = [cors1, cors2]
+    bucketName = "examplebucket"
+    # Configure CORS for the bucket.
+    resp = obsClient.setBucketCors(bucketName, corsList)
+
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Set Bucket Cors Succeeded')
+        print('requestId:', resp.requestId)
+    else:
+        print('Set Bucket Cors Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Set Bucket Cors Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0830.html b/docs/obs_3rd_party/python_sdk/obs_22_0830.html new file mode 100644 index 000000000..aded270a3 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0830.html @@ -0,0 +1,400 @@ + + +

Obtaining the CORS Configuration of a Bucket (SDK for Python)

+

Function

Cross-origin resource sharing (CORS) is a mechanism defined by the World Wide Web Consortium (W3C) that allows a web application program in one domain to access resources located in another one. For general web page requests, website scripts and contents in one domain cannot interact with those in another because of Same Origin Policies (SOPs). OBS supports CORS rules that allow the resources in OBS to be requested by other domains.

+

This API returns the CORS configuration of a bucket.

+
+

Restrictions

+
+

Method

ObsClient.getBucketCors(bucketName, extensionHeaders)

+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + +

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + +

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + +

GetResult.body Type

+

Description

+

list of CorsRule

+

Explanation:

+

CORS rule list of the bucket. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 CorsRule

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

id

+

str

+

No if used as a request parameter

+

Explanation:

+

CORS rule ID

+

Value range:

+

The value must contain 1 to 255 characters.

+

Default value:

+

None

+

allowedMethod

+

list of str

+

Yes if used as a request parameter

+

Explanation:

+

The allowed HTTP methods (types of operations on buckets and objects) for a cross-origin request.

+

Value range:

+

The following HTTP methods are supported:

+
  • GET
  • PUT
  • HEAD
  • POST
  • DELETE
+

Default value:

+

None

+

allowedOrigin

+

list of str

+

Yes if used as a request parameter

+

Explanation:

+

The origin from which the requests can access the bucket.

+

Restrictions:

+

Domain name of the origin. Each origin can contain only one wildcard character (*), for example, https://*.vbs.example.com.

+

Default value:

+

None

+

allowedHeader

+

list of str

+

No if used as a request parameter

+

Explanation:

+

The allowed headers for cross-origin requests. Only CORS requests matching the allowed headers are valid.

+

Restrictions:

+

Each header can contain at most one wildcard character (*). Spaces, ampersands (&), colons (:), less-than signs (<), and full-width characters are not allowed.

+

Default value:

+

None

+

maxAgeSecond

+

int

+

or

+

str

+

No if used as a request parameter

+

Explanation:

+

Time your client can cache the response for a cross-origin request

+

Restrictions:

+

Each CORS rule can contain at most one maxAgeSecond.

+

Value range:

+

An integer greater than or equal to 0, in seconds

+

Default value:

+

100

+

exposeHeader

+

list of str

+

No if used as a request parameter

+

Explanation:

+

The CORS-allowed additional headers in the response. These headers provide additional information to clients. By default, your browser can only access headers Content-Length and Content-Type. If your browser needs to access other headers, add them to a list of the allowed additional headers.

+

Restrictions:

+

Spaces, wildcard characters (*), ampersands (&), colons (:), and less-than signs (<) are not allowed.

+

Default value:

+

None

+
+
+
+

Code Examples

This example returns the CORS configuration of bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName = "examplebucket"
+    # Obtain the bucket's CORS configuration.
+    resp = obsClient.getBucketCors(bucketName)
+
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Get Bucket Cors Succeeded')
+        print('requestId:', resp.requestId)
+        index = 1
+        for rule in resp.body:
+            print('corsRule [' + str(index) + ']')
+            print('id:', rule.id)
+            print('allowedMethod', rule.allowedMethod)
+            print('allowedOrigin', rule.allowedOrigin)
+            print('allowedHeader', rule.allowedHeader)
+            print('maxAgeSecond', rule.maxAgeSecond)
+            print('exposeHeader', rule.exposeHeader)
+            index += 1
+    else:
+        print('Get Bucket Cors Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Get Bucket Cors Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0831.html b/docs/obs_3rd_party/python_sdk/obs_22_0831.html new file mode 100644 index 000000000..692333c21 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0831.html @@ -0,0 +1,261 @@ + + +

Deleting the CORS Configuration of a Bucket (SDK for Python)

+

Function

Cross-origin resource sharing (CORS) is a mechanism defined by the World Wide Web Consortium (W3C) that allows a web application program in one domain to access resources located in another one. For general web page requests, website scripts and contents in one domain cannot interact with those in another because of Same Origin Policies (SOPs). OBS supports CORS rules that allow the resources in OBS to be requested by other domains.

+

This API deletes the CORS configuration of a bucket.

+
+

Restrictions

+
+

Method

ObsClient.deleteBucketCors(bucketName, extensionHeaders)

+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + +

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + +

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+
+

Code Examples

This example deletes CORS rules of bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName = "examplebucket"
+    # Delete CORS rules of the bucket.
+    resp = obsClient.deleteBucketCors(bucketName)
+
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Delete Bucket Cors Succeeded')
+        print('requestId:', resp.requestId)
+    else:
+        print('Delete Bucket Cors Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Delete Bucket Cors Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0834.html b/docs/obs_3rd_party/python_sdk/obs_22_0834.html new file mode 100644 index 000000000..b8e7d12e7 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0834.html @@ -0,0 +1,352 @@ + + +

Configuring Tags for a Bucket (SDK for Python)

+

Function

If you add tags to a bucket, SDRs generated for the requests sent to this bucket will include these tags, so you can use the tags to classify SDRs for detailed cost analysis. For example, if you have an application that uploads its running data to a bucket, you can tag the bucket with the application name. In this manner, the costs on the application can be analyzed using tags in SDRs.

+

This API adds tags to a bucket.

+
+

Restrictions

+
+

Method

ObsClient.setBucketTagging(bucketName, tagInfo, extensionHeaders)

+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + +

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

tagInfo

+

TagInfo

+

Yes

+

Explanation:

+

Bucket tag list. For details, see Table 1.

+

Restrictions:

+
  • A bucket can have a maximum of 10 tags. Each tag can have only one pair of key values.
  • For the same bucket, tag keys must be unique, but tag values can be duplicated or left blank.
+

Default value:

+

None

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + +
Table 1 TagInfo

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

tagSet

+

list of Tag

+

Yes if used as a request parameter

+

Explanation:

+

Bucket tag list. For details, see Table 2.

+

Restrictions:

+
  • A bucket can have a maximum of 10 tags. Each tag can have only one pair of key values.
  • For the same bucket, tag keys must be unique, but tag values can be duplicated or left blank.
+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 2 Tag

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

key

+

str

+

Yes if used as a request parameter

+

Explanation:

+

Tag key

+

Restrictions:

+
  • The tag key in the same bucket must be unique.
  • The value of the key can be self-defined or predefined by TMS.
  • The key must contain 1 to 128 characters.
  • Tag keys cannot start or end with a space and cannot contain commas (,), asterisks (*), vertical bars (|), slashes (/), less-than signs (<), greater-than signs (>), equal signs (=), backslashes (\), or ASCII control characters (0x00 to 0x1F). Tag keys and values must be URL encoded before being sent to a server.
  • The value is case-sensitive.
+

Default value:

+

None

+

value

+

str

+

Yes if used as a request parameter

+

Explanation:

+

Tag value

+

Restrictions:

+

Tag values can be duplicated or left blank.

+
  • The value must contain 0 to 255 characters.
  • Tag values cannot start or end with a space and cannot contain commas (,), asterisks (*), vertical bars (|), slashes (/), less-than signs (<), greater-than signs (>), equal signs (=), backslashes (\), or ASCII control characters (0x00 to 0x1F). Tag keys and values must be URL encoded before being sent to a server.
  • The value is case-sensitive.
+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + +

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+
+

Code Examples

This example configures tags for bucket examplebucket.
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
from obs import ObsClient
+from obs import TagInfo
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    tagInfo = TagInfo()
+    # Specify the label content.
+    tagInfo.addTag('tag1', 'value1').addTag('tag2', 'value2')
+    bucketName="examplebucket"
+    # Configure tags for the bucket.
+    resp = obsClient.setBucketTagging(bucketName, tagInfo)
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Set Bucket Tagging Succeeded')
+        print('requestId:', resp.requestId)
+    else:
+        print('Set Bucket Tagging Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Set Bucket Taggingg Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0835.html b/docs/obs_3rd_party/python_sdk/obs_22_0835.html new file mode 100644 index 000000000..da8fc4bcf --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0835.html @@ -0,0 +1,358 @@ + + +

Obtaining Bucket Tags (SDK for Python)

+

Function

If you add tags to a bucket, SDRs generated for the requests sent to this bucket will include these tags, so you can use the tags to classify SDRs for detailed cost analysis. For example, if you have an application that uploads its running data to a bucket, you can tag the bucket with the application name. In this manner, the costs on the application can be analyzed using tags in SDRs.

+

This API returns the tags of a bucket.

+
+

Restrictions

+
+

Method

ObsClient.getBucketTagging(bucketName, extensionHeaders)

+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + +

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + +

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + +

GetResult.body Type

+

Description

+

TagInfo

+

Explanation:

+

Bucket tag configuration. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + +
Table 2 TagInfo

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

tagSet

+

list of Tag

+

Yes if used as a request parameter

+

Explanation:

+

Bucket tag list. For details, see Table 3.

+

Restrictions:

+
  • A bucket can have a maximum of 10 tags. Each tag can have only one pair of key values.
  • For the same bucket, tag keys must be unique, but tag values can be duplicated or left blank.
+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 3 Tag

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

key

+

str

+

Yes if used as a request parameter

+

Explanation:

+

Tag key

+

Restrictions:

+
  • The tag key in the same bucket must be unique.
  • The value of the key can be self-defined or predefined by TMS.
  • The key must contain 1 to 128 characters.
  • Tag keys cannot start or end with a space and cannot contain commas (,), asterisks (*), vertical bars (|), slashes (/), less-than signs (<), greater-than signs (>), equal signs (=), backslashes (\), or ASCII control characters (0x00 to 0x1F). Tag keys and values must be URL encoded before being sent to a server.
  • The value is case-sensitive.
+

Default value:

+

None

+

value

+

str

+

Yes if used as a request parameter

+

Explanation:

+

Tag value

+

Restrictions:

+

Tag values can be duplicated or left blank.

+
  • The value must contain 0 to 255 characters.
  • Tag values cannot start or end with a space and cannot contain commas (,), asterisks (*), vertical bars (|), slashes (/), less-than signs (<), greater-than signs (>), equal signs (=), backslashes (\), or ASCII control characters (0x00 to 0x1F). Tag keys and values must be URL encoded before being sent to a server.
  • The value is case-sensitive.
+

Default value:

+

None

+
+
+
+

Code Examples

This example returns tags of bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName="examplebucket"
+    # Obtain bucket tags.
+    resp = obsClient.getBucketTagging(bucketName)
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Get Bucket Tagging Succeeded')
+        print('requestId:', resp.requestId)
+        index = 1
+        for tag in resp.body.tagSet:
+            print('tag [' + str(index) + ']')
+            print('key:', tag.key)
+            print('value:', tag.value)
+            index += 1
+    else:
+        print('Get Bucket Tagging Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Get Bucket Tagging Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0836.html b/docs/obs_3rd_party/python_sdk/obs_22_0836.html new file mode 100644 index 000000000..7e01b34cd --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0836.html @@ -0,0 +1,259 @@ + + +

Deleting Bucket Tags (SDK for Python)

+

Function

If you add tags to a bucket, SDRs generated for the requests sent to this bucket will include these tags, so you can use the tags to classify SDRs for detailed cost analysis. For example, if you have an application that uploads its running data to a bucket, you can tag the bucket with the application name. In this manner, the costs on the application can be analyzed using tags in SDRs.

+

This API deletes the tags of a bucket.

+
+

Restrictions

+
+

Method

ObsClient.deleteBucketTagging(bucketName, extensionHeaders)

+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + +

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + +

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+
+

Code Examples

This example deletes tags of bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName="examplebucket"
+    # Delete bucket tags.
+    resp = obsClient.deleteBucketTagging(bucketName)
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Delete Bucket Tagging Succeeded')
+        print('requestId:', resp.requestId)
+    else:
+        print('Delete Bucket Tagging Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Delete Bucket Tagging Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0900.html b/docs/obs_3rd_party/python_sdk/obs_22_0900.html new file mode 100644 index 000000000..1c8b1474e --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0900.html @@ -0,0 +1,57 @@ + + +

Object-Related APIs (SDK for Python)

+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0901.html b/docs/obs_3rd_party/python_sdk/obs_22_0901.html new file mode 100644 index 000000000..45e9b58ac --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0901.html @@ -0,0 +1,916 @@ + + +

Uploading Objects - Text-Based (SDK for Python)

+

Function

This API uploads the text using strings as the data source to a specified bucket.

+
+

Restrictions

+
+

Method

ObsClient.putContent(bucketName, objectKey, content, metadata, headers, progressCallback, autoClose, extensionHeaders)
+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

str

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

content

+

str or readable object

+

No

+

Explanation:

+

Content of the object to be uploaded

+

Value range:

+

A string or a readable object

+
NOTE:

If content is a readable object that contains the read attribute, data is read from the readable object. Otherwise, the object content is a string.

+
+

Default value:

+

None

+

metadata

+

dict

+

No

+

Explanation:

+

Custom metadata of the object to be uploaded. You can add a header starting with x-obs-meta- in the request to define metadata. The custom metadata will be returned in the response when you retrieve the object or query the object metadata.

+

Restrictions:

+
  • The custom metadata cannot exceed 8 KB. To measure the custom metadata, sum the number of bytes in the UTF-8 encoding of each key and value.
  • The custom metadata keys are case insensitive, but are stored in lowercase in OBS. The key values are case sensitive.
  • Both custom metadata keys and their values must conform to US-ASCII standards. If non-ASCII or unrecognizable characters are required, they must be encoded and decoded in URL or Base64 on the client, because the server does not perform such operations.
+

Default value:

+

None

+

headers

+

PutObjectHeader

+

No

+

Explanation:

+

Headers in the request used for configuring the storage class, redundancy policy, and other basic information about the object

+

Value range:

+

See Table 2.

+

Default value:

+

None

+

progressCallback

+

callable

+

No

+

Explanation:

+

Callback function for obtaining the upload progress

+

Default value:

+

None

+
NOTE:

This function contains the following parameters in sequence: number of uploaded bytes, total number of bytes, and used time (in seconds). For details about the sample code, see Obtaining the Upload Progress (SDK for Python).

+

Upload progress callback only supports streaming, file-based, multipart, appendable, and resumable uploads.

+
+

autoClose

+

bool

+

No

+

Explanation:

+

Whether or not to automatically close data streams after the upload is complete

+

Value range:

+

True: The data stream is automatically closed.

+

False: The data stream is not automatically closed.

+

Default value:

+

True

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 PutObjectHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

md5

+

str

+

No

+

Explanation:

+

Base64-encoded MD5 value of the data to be uploaded. It is used for the OBS server to verify data integrity.

+

Value range:

+

Base64-encoded 128-bit MD5 value of the request body calculated according to RFC 1864

+

Example: n58IG6hfM7vqI4K0vnWpog==

+

Default value:

+

None

+

acl

+

str

+

No

+

Explanation:

+

Pre-defined access policy specified during object creation.

+

Value range:

+

See Table 3.

+

Default value:

+

None

+

location

+

str

+

No

+

Explanation:

+

If the bucket is configured with website hosting, the request for obtaining the object can be redirected to another object in the bucket or an external URL.

+

The request is redirected to object anotherPage.html in the same bucket:

+

location:/anotherPage.html

+

The request is redirected to an external URL http://www.example.com/:

+

location:http://www.example.com/

+

OBS obtains the specified value from the header and stores it in the object metadata location.

+

Restrictions:

+
  • The value must start with a slash (/), http://, or https:// and cannot exceed 2 KB.
  • OBS only supports redirection for objects in the root directory of a bucket.
+

Default value:

+

None

+

contentType

+

str

+

No

+

Explanation:

+

Multipurpose Internet Mail Extensions (MIME) type of the object to be uploaded. MIME type is a standard way of describing a data type and is used by the browser to decide how to display data.

+

Value range:

+

See What Is Content-Type (MIME)? (Python SDK)

+

Default value:

+

If you do not specify contentType when uploading an object, the SDK determines the object type based on the suffix of the specified object name and automatically assigns a value to contentType.

+

contentLength

+

int

+

No

+

Explanation:

+

Size of the object to be uploaded

+

Restrictions:

+
  • The object size in a single upload ranges from 0 to 5 GB.
  • To upload files larger than 5 GB, multipart uploads should be used.
+

Default value:

+

If this parameter is not specified, OBS SDK for Python automatically calculates the size of the object.

+

sseHeader

+

SseCHeader or SseKmsHeader

+

No

+

Explanation:

+

Header for server-side encryption. For details, see Table 5 or Table 6.

+

Default value:

+

None

+

storageClass

+

str

+

No

+

Explanation:

+

Storage class of the object to be uploaded

+

Value range:

+

See Table 4.

+

Default value:

+

None

+

successActionRedirect

+

str

+

No

+

Explanation:

+

Address (URL) to which a successfully answered request is redirected

+
  • If the value is valid and the request is successful, OBS returns status code 303. Location in the returned results contains SuccessActionRedirect as well as the bucket name, object name, and object ETag.
  • If the value is invalid, OBS ignores this parameter. In such case, Location in the returned results indicates the object address, and OBS returns a status code based on whether the operation succeeds or fails.
+

Default value:

+

None

+

extensionGrants

+

list of ExtensionGrant

+

No

+

Explanation:

+

List of the extended permissions for the object to be uploaded

+

Value range:

+

See Table 7.

+

Default value:

+

None

+

expires

+

int

+

No

+

Explanation:

+

Expiration time of the object (calculated from the latest modification time of the object). Expired objects are automatically deleted.

+

Restrictions:

+

This parameter can be configured only when uploading the object. It cannot be modified by calling a metadata modification API.

+

Value range:

+

An integer greater than or equal to 0, in days

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 HeadPermission

Constant

+

Default Value

+

Description

+

HeadPermission.PRIVATE

+

private

+

Private read/write

+

A bucket or object can only be accessed by its owner.

+

HeadPermission.PUBLIC_READ

+

public-read

+

Public read and private write

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, metadata, and object versions in the bucket.

+

If it is granted on an object, anyone can read the content and metadata of the object.

+

HeadPermission.PUBLIC_READ_WRITE

+

public-read-write

+

Public read/write

+

If this permission is granted on a bucket, anyone can read the object list, multipart tasks, metadata, and object versions in the bucket, and can upload or delete objects, initiate multipart upload tasks, upload parts, assemble parts, copy parts, and abort multipart upload tasks.

+

If it is granted on an object, anyone can read the content and metadata of the object.

+

HeadPermission.PUBLIC_READ_DELIVERED

+

public-read-delivered

+

Public read on a bucket as well as objects in the bucket

+

If this permission is granted on a bucket, anyone can read the object list, multipart tasks, metadata, and object versions, and read the content and metadata of objects in the bucket.

+
NOTE:

PUBLIC_READ_DELIVERED cannot be applied to objects.

+
+

HeadPermission.PUBLIC_READ_WRITE_DELIVERED

+

public-read-write-delivered

+

Public read/write on a bucket as well as objects in the bucket

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, metadata, and object versions in the bucket, and can upload or delete objects, initiate multipart upload tasks, upload parts, assemble parts, copy parts, and abort multipart uploads. They can also read the content and metadata of objects in the bucket.

+
NOTE:

PUBLIC_READ_WRITE_DELIVERED cannot be applied to objects.

+
+

HeadPermission.BUCKET_OWNER_FULL_CONTROL

+

public-read-write-delivered

+

If this permission is granted on an object, only the bucket and object owners have the full control over the object. By default, if you upload an object to a bucket of any other user, the bucket owner does not have the permissions on your object. After you grant this policy to the bucket owner, the bucket owner can have full control over your object.

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 4 StorageClass

Parameter

+

Type

+

Description

+

STANDARD

+

Standard storage class

+

Explanation:

+

Features low access latency and high throughput and is used for storing massive, frequently accessed (multiple times a month) or small objects (< 1 MB) requiring quick response.

+

WARM

+

Warm storage class

+

Explanation:

+

Used for storing data that is semi-frequently accessed (fewer than 12 times a year) but is instantly available when needed.

+

COLD

+

Cold storage class

+

Explanation:

+

Used for storing rarely accessed (once a year) data.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 5 SseCHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

encryption

+

str

+

Yes

+

Explanation:

+

SSE-C used for encrypting objects

+

Value range:

+

AES256

+

Default value:

+

None

+

key

+

str

+

Yes

+

Explanation:

+

Key used in SSE-C encryption. It corresponds to the encryption method. For example, if encryption is set to AES256, the key is calculated using the AES-256 algorithm.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 6 SseKmsHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

encryption

+

str

+

Yes

+

Explanation:

+

SSE-KMS used for encrypting objects

+

Value range:

+

kms

+

Default value:

+

None

+

key

+

str

+

No

+

Explanation:

+

Master key used in SSE-KMS

+

Value range:

+

The following two formats are supported:

+
  • regionID:domainID:key/key_id
  • key_id
+

In the preceding formats:

+ +

Default value:

+
  • If this parameter is not specified, the default master key will be used.
  • If there is no such a default master key, OBS will create one and use it by default.
+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 7 ExtensionGrant

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

granteeId

+

str

+

No

+

Explanation:

+

Account (domain) ID of the grantee

+

Value range:

+

See How Do I Get My Account ID and IAM User ID? (SDK for Python)

+

Default value:

+

None

+

permission

+

str

+

No

+

Explanation:

+

Granted permissions

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
Table 8 Permission

Constant

+

Description

+

READ

+

Read permission

+

A grantee with this permission for a bucket can obtain the list of objects, multipart uploads, bucket metadata, and object versions in the bucket.

+

A grantee with this permission for an object can obtain the object content and metadata.

+

WRITE

+

Write permission

+

A grantee with this permission for a bucket can upload, overwrite, and delete any object or part in the bucket.

+

Such permission for an object is not applicable.

+

READ_ACP

+

Permission to read ACL configurations

+

A grantee with this permission can obtain the ACL of a bucket or object.

+

A bucket or object owner has this permission for the bucket or object permanently.

+

WRITE_ACP

+

Permission to modify ACL configurations

+

A grantee with this permission can update the ACL of a bucket or object.

+

A bucket or object owner has this permission for the bucket or object permanently.

+

A grantee with this permission can modify the access control policy and thus the grantee obtains full access permissions.

+

FULL_CONTROL

+

Full control access, including read and write permissions for a bucket and its ACL, or for an object and its ACL.

+

A grantee with this permission for a bucket has READ, WRITE, READ_ACP, and WRITE_ACP permissions for the bucket.

+

A grantee with this permission for an object has READ, READ_ACP, and WRITE_ACP permissions for the object.

+
+
+

Responses

+
+ + + + + + + +
Table 9 List of returned results

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 10 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + +
Table 11 GetResult.body

GetResult.body Type

+

Description

+

PutContentResponse

+

Explanation:

+

Response to the request for uploading an object. For details, see Table 12.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 12 PutContentResponse

Parameter

+

Type

+

Description

+

storageClass

+

str

+

Explanation:

+

Storage class of the object to be uploaded

+

Value range:

+
  • If the storage class is Standard, leave this parameter blank.
  • For details about the available storage classes, see Table 4.
+

Default value:

+

None

+

versionId

+

str

+

Explanation:

+

Object version ID. If versioning is enabled for the bucket, the object version ID will be returned.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

etag

+

str

+

Explanation:

+

ETag of an object, which is a base64-encoded 128-bit MD5 digest. ETag is the unique identifier of the object content. It can be used to determine whether the object content is changed. For example, if the ETag is A when an object is uploaded and is B when the object is downloaded, the object content is changed. The ETag reflects changes only to the contents of the object, not its metadata. An uploaded object or copied object has a unique ETag.

+

Restrictions:

+

If an object is encrypted using server-side encryption, the ETag is not the MD5 value of the object.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

sseKms

+

str

+

Explanation:

+

SSE-KMS algorithm

+

Value range:

+

kms

+

Default value:

+

None

+

sseKmsKey

+

str

+

Explanation:

+

ID of the KMS master key when SSE-KMS is used

+

Value range:

+

Valid value formats are as follows:

+
  1. regionID:domainID:key/key_id
  2. key_id
+

In the preceding formats:

+ +

Default value:

+
  • If this parameter is not specified, the default master key will be used.
  • If there is no such a default master key, the system will create one and use it by default.
+

sseC

+

str

+

Explanation:

+

SSE-C algorithm

+

Value range:

+

Advanced Encryption Standard 256 (AES256)

+

Default value:

+

None

+

sseCKeyMd5

+

str

+

Explanation:

+

MD5 value of the key for encrypting objects when SSE-C is used. This value is used to check whether any error occurs during the transmission of the key.

+

Restrictions:

+

The value is encrypted by MD5 and then encoded by Base64, for example, 4XvB3tbNTN+tIEVa0/fGaQ==.

+

Default value:

+

None

+

objectUrl

+

str

+

Explanation:

+

Full path to the object

+

Default value:

+

None

+
+
+
+

Code Examples

This example uploads a text.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+# Before running the sample code, ensure that the environment variables AccessKeyID and SecretAccessKey have been configured.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName = "examplebucket"
+    objectKey = "objectname"
+    # Specify the text to be uploaded.
+    content = 'Hello OBS'
+    # Upload the text.
+    resp = obsClient.putContent(bucketName, objectKey, content)
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Put Content Succeeded')
+        print('requestId:', resp.requestId)
+        print('etag:', resp.body.etag)
+    else:
+        print('Put Content Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Put Content Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0902.html b/docs/obs_3rd_party/python_sdk/obs_22_0902.html new file mode 100644 index 000000000..b0f40a80d --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0902.html @@ -0,0 +1,1008 @@ + + +

Uploading an Object - Streaming (SDK for Python)

+

Function

You can upload texts, images, videos, or any other types of files smaller than 5 GB.

+

Streaming upload uses readable objects that contain the read attribute as the data source and uploads data to a specified bucket in network streams or file streams.

+
+

Restrictions

+
+

Method

ObsClient.putContent(bucketName, objectKey, content, metadata, headers, progressCallback, autoClose, extensionHeaders)
+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

str

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

content

+

str

+

or

+

readable object

+

No

+

Explanation:

+

Content of the object to be uploaded

+

Value range:

+
NOTICE:
  • Streaming upload requires CONTENT to be a readable object that contains the READ attribute.
  • When uploading file streams, you must open files in RB or RB+ mode.
+
+

Default value:

+

None

+

metadata

+

dict

+

No

+

Explanation:

+

Custom metadata of the object to be uploaded. You can add a header starting with x-obs-meta- in the request to define metadata. The custom metadata will be returned in the response when you retrieve the object or query the object metadata.

+

Restrictions:

+
  • The custom metadata cannot exceed 8 KB. To measure the custom metadata, sum the number of bytes in the UTF-8 encoding of each key and value.
  • The custom metadata keys are case insensitive, but are stored in lowercase in OBS. The key values are case sensitive.
  • Both custom metadata keys and their values must conform to US-ASCII standards. If non-ASCII or unrecognizable characters are required, they must be encoded and decoded in URL or Base64 on the client, because the server does not perform such operations.
+

Default value:

+

None

+

headers

+

PutObjectHeader

+

No

+

Explanation:

+

Headers in the request used for configuring the storage class, redundancy policy, and other basic information about the object

+

Value range:

+

See Table 2.

+

Default value:

+

None

+

progressCallback

+

callable

+

No

+

Explanation:

+

Callback function for obtaining the upload progress

+

Default value:

+

None

+
NOTE:

This function contains the following parameters in sequence: number of uploaded bytes, total number of bytes, and used time (in seconds). For details about the sample code, see Obtaining the Upload Progress (SDK for Python).

+

Upload progress callback only supports streaming, file-based, multipart, appendable, and resumable uploads.

+
+

autoClose

+

bool

+

No

+

Explanation:

+

Whether or not to automatically close data streams after the upload is complete

+

Value range:

+

True: The data stream is automatically closed.

+

False: The data stream is not automatically closed.

+

Default value:

+

True

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 PutObjectHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

md5

+

str

+

No

+

Explanation:

+

Base64-encoded MD5 value of the data to be uploaded. It is used for the OBS server to verify data integrity.

+

Value range:

+

Base64-encoded 128-bit MD5 value of the request body calculated according to RFC 1864

+

Example: n58IG6hfM7vqI4K0vnWpog==

+

Default value:

+

None

+

acl

+

str

+

No

+

Explanation:

+

Pre-defined access policy specified during object creation.

+

Value range:

+

See Table 3.

+

Default value:

+

None

+

location

+

str

+

No

+

Explanation:

+

If the bucket is configured with website hosting, the request for obtaining the object can be redirected to another object in the bucket or an external URL.

+

The request is redirected to object anotherPage.html in the same bucket:

+

location:/anotherPage.html

+

The request is redirected to an external URL http://www.example.com/:

+

location:http://www.example.com/

+

OBS obtains the specified value from the header and stores it in the object metadata location.

+

Restrictions:

+
  • The value must start with a slash (/), http://, or https:// and cannot exceed 2 KB.
  • OBS only supports redirection for objects in the root directory of a bucket.
+

Default value:

+

None

+

contentType

+

str

+

No

+

Explanation:

+

MIME type of the file to be uploaded. MIME type is a standard way of describing a data type and is used by the browser to decide how to display data.

+

Value range:

+

See What Is Content-Type (MIME)? (Python SDK)

+

Default value:

+

If you do not specify contentType when uploading an object, the SDK determines the object type based on the suffix of the specified object name and automatically assigns a value to contentType.

+

contentLength

+

int

+

No

+

Explanation:

+

Size of the object to be uploaded

+

Restrictions:

+
  • The object size in a single upload ranges from 0 to 5 GB.
  • To upload files larger than 5 GB, multipart uploads should be used.
+

Default value:

+

If this parameter is not specified, OBS SDK for Python automatically calculates the size of the object.

+

sseHeader

+

SseCHeader

+

or

+

SseKmsHeader

+

No

+

Explanation:

+

Header for server-side encryption. For details, see Table 5 or Table 6.

+

Default value:

+

None

+

storageClass

+

str

+

No

+

Explanation:

+

Storage class of the object

+

Value range:

+

See Table 4.

+

Default value:

+

None

+

successActionRedirect

+

str

+

No

+

Explanation:

+

Address (URL) to which a successfully answered request is redirected

+
  • If the value is valid and the request is successful, OBS returns status code 303. Location in the returned results contains SuccessActionRedirect as well as the bucket name, object name, and object ETag.
  • If the value is invalid, OBS ignores this parameter. In such case, Location in the returned results indicates the object address, and OBS returns a status code based on whether the operation succeeds or fails.
+

Default value:

+

None

+

extensionGrants

+

list of ExtensionGrant

+

No

+

Explanation:

+

List of the extended permissions for the object to be uploaded

+

Value range:

+

See Table 7.

+

Default value:

+

None

+

expires

+

int

+

No

+

Explanation:

+

Expiration time of the object (calculated from the latest modification time of the object). Expired objects are automatically deleted.

+

Restrictions:

+

This parameter can be configured only when uploading the object. It cannot be modified by calling a metadata modification API.

+

Value range:

+

An integer greater than or equal to 0, in days

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 HeadPermission

Constant

+

Default Value

+

Description

+

HeadPermission.PRIVATE

+

private

+

Private read/write

+

A bucket or object can only be accessed by its owner.

+

HeadPermission.PUBLIC_READ

+

public-read

+

Public read and private write

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, metadata, and object versions in the bucket.

+

If it is granted on an object, anyone can read the content and metadata of the object.

+

HeadPermission.PUBLIC_READ_WRITE

+

public-read-write

+

Public read/write

+

If this permission is granted on a bucket, anyone can read the object list, multipart tasks, metadata, and object versions in the bucket, and can upload or delete objects, initiate multipart upload tasks, upload parts, assemble parts, copy parts, and abort multipart upload tasks.

+

If it is granted on an object, anyone can read the content and metadata of the object.

+

HeadPermission.PUBLIC_READ_DELIVERED

+

public-read-delivered

+

Public read on a bucket as well as objects in the bucket

+

If this permission is granted on a bucket, anyone can read the object list, multipart tasks, metadata, and object versions, and read the content and metadata of objects in the bucket.

+
NOTE:

PUBLIC_READ_DELIVERED cannot be applied to objects.

+
+

HeadPermission.PUBLIC_READ_WRITE_DELIVERED

+

public-read-write-delivered

+

Public read/write on a bucket as well as objects in the bucket

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, metadata, and object versions in the bucket, and can upload or delete objects, initiate multipart upload tasks, upload parts, assemble parts, copy parts, and abort multipart uploads. They can also read the content and metadata of objects in the bucket.

+
NOTE:

PUBLIC_READ_WRITE_DELIVERED cannot be applied to objects.

+
+

HeadPermission.BUCKET_OWNER_FULL_CONTROL

+

public-read-write-delivered

+

If this permission is granted on an object, only the bucket and object owners have the full control over the object. By default, if you upload an object to a bucket of any other user, the bucket owner does not have the permissions on your object. After you grant this policy to the bucket owner, the bucket owner can have full control over your object.

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 4 StorageClass

Parameter

+

Type

+

Description

+

STANDARD

+

Standard storage class

+

Explanation:

+

Features low access latency and high throughput and is used for storing massive, frequently accessed (multiple times a month) or small objects (< 1 MB) requiring quick response.

+

WARM

+

Warm storage class

+

Explanation:

+

Used for storing data that is semi-frequently accessed (fewer than 12 times a year) but is instantly available when needed.

+

COLD

+

Cold storage class

+

Explanation:

+

Used for storing rarely accessed (once a year) data.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 5 SseCHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

encryption

+

str

+

Yes

+

Explanation:

+

SSE-C used for encrypting objects

+

Value range:

+

AES256

+

Default value:

+

None

+

key

+

str

+

Yes

+

Explanation:

+

Key used in SSE-C encryption. It corresponds to the encryption method. For example, if encryption is set to AES256, the key is calculated using the AES-256 algorithm.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 6 SseKmsHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

encryption

+

str

+

Yes

+

Explanation:

+

SSE-KMS used for encrypting objects

+

Value range:

+

kms

+

Default value:

+

None

+

key

+

str

+

No

+

Explanation:

+

Master key used in SSE-KMS

+

Value range:

+

The following two formats are supported:

+
  • regionID:domainID:key/key_id
  • key_id
+

In the preceding formats:

+ +

Default value:

+
  • If this parameter is not specified, the default master key will be used.
  • If there is no such a default master key, OBS will create one and use it by default.
+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 7 ExtensionGrant

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

granteeId

+

str

+

No

+

Explanation:

+

Account (domain) ID of the grantee

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and IAM User ID? (SDK for Python)

+

Default value:

+

None

+

permission

+

str

+

No

+

Explanation:

+

Granted permissions

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
Table 8 Permission

Constant

+

Description

+

READ

+

Read permission

+

A grantee with this permission for a bucket can obtain the list of objects, multipart uploads, bucket metadata, and object versions in the bucket.

+

A grantee with this permission for an object can obtain the object content and metadata.

+

WRITE

+

Write permission

+

A grantee with this permission for a bucket can upload, overwrite, and delete any object or part in the bucket.

+

Such permission for an object is not applicable.

+

READ_ACP

+

Permission to read ACL configurations

+

A grantee with this permission can obtain the ACL of a bucket or object.

+

A bucket or object owner has this permission for the bucket or object permanently.

+

WRITE_ACP

+

Permission to modify ACL configurations

+

A grantee with this permission can update the ACL of a bucket or object.

+

A bucket or object owner has this permission for the bucket or object permanently.

+

A grantee with this permission can modify the access control policy and thus the grantee obtains full access permissions.

+

FULL_CONTROL

+

Full control access, including read and write permissions for a bucket and its ACL, or for an object and its ACL.

+

A grantee with this permission for a bucket has READ, WRITE, READ_ACP, and WRITE_ACP permissions for the bucket.

+

A grantee with this permission for an object has READ, READ_ACP, and WRITE_ACP permissions for the object.

+
+
+

Responses

+
+ + + + + + + +
Table 9 List of returned results

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 10 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + +
Table 11 GetResult.body

GetResult.body Type

+

Description

+

PutContentResponse

+

Explanation:

+

Response to the request for uploading an object. For details, see Table 12.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 12 PutContentResponse

Parameter

+

Type

+

Description

+

storageClass

+

str

+

Explanation:

+

Storage class of the object

+

Value range:

+
  • If the storage class is Standard, leave this parameter blank.
  • For details about the available storage classes, see Table 4.
+

Default value:

+

None

+

versionId

+

str

+

Explanation:

+

Object version ID. If versioning is enabled for the bucket, the object version ID will be returned.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

etag

+

str

+

Explanation:

+

ETag of an object, which is a base64-encoded 128-bit MD5 digest. ETag is the unique identifier of the object content. It can be used to determine whether the object content is changed. For example, if the ETag is A when an object is uploaded and is B when the object is downloaded, the object content is changed. The ETag reflects changes only to the contents of the object, not its metadata. An uploaded object or copied object has a unique ETag.

+

Restrictions:

+

If an object is encrypted using server-side encryption, the ETag is not the MD5 value of the object.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

sseKms

+

str

+

Explanation:

+

SSE-KMS algorithm

+

Value range:

+

kms

+

Default value:

+

None

+

sseKmsKey

+

str

+

Explanation:

+

ID of the KMS master key when SSE-KMS is used

+

Value range:

+

Valid value formats are as follows:

+
  1. regionID:domainID:key/key_id
  2. key_id
+

In the preceding formats:

+ +

Default value:

+
  • If this parameter is not specified, the default master key will be used.
  • If there is no such a default master key, the system will create one and use it by default.
+

sseC

+

str

+

Explanation:

+

SSE-C algorithm

+

Value range:

+

AES256

+

Default value:

+

None

+

sseCKeyMd5

+

str

+

Explanation:

+

MD5 value of the key for encrypting objects when SSE-C is used. This value is used to check whether any error occurs during the transmission of the key.

+

Restrictions:

+

The value is encrypted by MD5 and then encoded by Base64, for example, 4XvB3tbNTN+tIEVa0/fGaQ==.

+

Default value:

+

None

+

objectUrl

+

str

+

Explanation:

+

Full path to the object

+

Default value:

+

None

+
+
+
+

Code Examples

This example uploads a network stream.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
from obs import ObsClient
+import os
+import traceback
+import sys
+if sys.version_info.major == 2 or not sys.version > '3':
+    import httplib
+else:
+    import http.client as httplib
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+# Specify a network stream.
+    conn = httplib.HTTPConnection('www.a.com', 80)
+// Obtain the network stream.
+    conn.request('GET', '/')
+    # Read the network stream.
+    content = conn.getresponse()
+    bucketName = "examplebucket"
+    objectKey = "objectname"
+    # Upload the network stream.
+    resp = obsClient.putContent(bucketName, objectKey, content)
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Put Content Succeeded')
+        print('requestId:', resp.requestId)
+    else:
+        print('Put Content Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Put Content Failed')
+    print(traceback.format_exc())
+
+
+

This example uploads a file stream.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    # Read a file stream.
+    content = open('localfile', 'rb')
+    bucketName = "examplebucket"
+    objectKey = "objectname"
+    # Upload the file stream.
+    resp = obsClient.putContent(bucketName, objectKey, content)
+
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Put Content Succeeded')
+        print('requestId:', resp.requestId)
+    else:
+        print('Put Content Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Put Content Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0903.html b/docs/obs_3rd_party/python_sdk/obs_22_0903.html new file mode 100644 index 000000000..54bd81608 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0903.html @@ -0,0 +1,1162 @@ + + +

Uploading an Object - File-Based (SDK for Python)

+

Function

This API uploads local files to OBS over the Internet. These files can be texts, images, videos, or any other type of files.

+
  • OBS does not involve folders like in a file system. All elements stored in OBS buckets are objects. To create a folder in OBS is essentially to create an object whose size is 0 and whose name ends with a slash (/). You can perform download, delete, or other operations on such objects as you do on ordinary objects.
  • If versioning is enabled, when uploading an object, OBS automatically allocates a unique version ID for the object. Objects with the same name are stored in OBS as objects with different version IDs. If versioning is not enabled, when uploading an object to a folder where there is already an object with the same name, the new object will overwrite the existing one.
  • You can pass user-defined headers in extensionHeaders in a dictionary. For details, see User-defined Header (SDK for Python).
+
+
+

Restrictions

+
+

Method

ObsClient.putFile(bucketName, objectKey, file_path, metadata, headers, progressCallback, extensionHeaders)
+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

str

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

file_path

+

str

+

Yes

+

Explanation:

+

Full path of the file or folder to be uploaded, for example, aa/bb.txt or aa/.

+

Default value:

+

None

+
NOTE:

If file_path is a folder, contentLength, md5, and contentType in headers cannot take effect.

+
+

metadata

+

dict

+

No

+

Explanation:

+

Custom metadata of the object to be uploaded. You can add a header starting with x-obs-meta- in the request to define metadata. The custom metadata will be returned in the response when you retrieve the object or query the object metadata.

+

Restrictions:

+
  • The custom metadata cannot exceed 8 KB. To measure the custom metadata, sum the number of bytes in the UTF-8 encoding of each key and value.
  • The custom metadata keys are case insensitive, but are stored in lowercase in OBS. The key values are case sensitive.
  • Both custom metadata keys and their values must conform to US-ASCII standards. If non-ASCII or unrecognizable characters are required, they must be encoded and decoded in URL or Base64 on the client, because the server does not perform such operations.
+

Default value:

+

None

+

headers

+

PutObjectHeader

+

No

+

Explanation:

+

Headers in the request used for configuring the storage class, redundancy policy, and other basic information about the object

+

Value range:

+

See Table 2.

+

Default value:

+

None

+

progressCallback

+

callable

+

No

+

Explanation:

+

Callback function for obtaining the upload progress

+

Restrictions:

+

The progress of a folder upload cannot be obtained.

+

Default value:

+

None

+
NOTE:

This function contains the following parameters in sequence: number of uploaded bytes, total number of bytes, and used time (in seconds). For details about the sample code, see Obtaining the Upload Progress (SDK for Python).

+

Upload progress callback only supports streaming, file-based, multipart, appendable, and resumable uploads.

+
+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 PutObjectHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

md5

+

str

+

No

+

Explanation:

+

Base64-encoded MD5 value of the data to be uploaded. It is used for the OBS server to verify data integrity.

+

Value range:

+

Base64-encoded 128-bit MD5 value of the request body calculated according to RFC 1864

+

Example: n58IG6hfM7vqI4K0vnWpog==

+

Default value:

+

None

+

acl

+

str

+

No

+

Explanation:

+

Pre-defined access policy specified during object creation.

+

Value range:

+

See Table 3.

+

Default value:

+

None

+

location

+

str

+

No

+

Explanation:

+

If the bucket is configured with website hosting, the request for obtaining the object can be redirected to another object in the bucket or an external URL.

+

The request is redirected to object anotherPage.html in the same bucket:

+

location:/anotherPage.html

+

The request is redirected to an external URL http://www.example.com/:

+

location:http://www.example.com/

+

OBS obtains the specified value from the header and stores it in the object metadata location.

+

Restrictions:

+
  • The value must start with a slash (/), http://, or https:// and cannot exceed 2 KB.
  • OBS only supports redirection for objects in the root directory of a bucket.
+

Default value:

+

None

+

contentType

+

str

+

No

+

Explanation:

+

MIME type of the file to be uploaded. MIME type is a standard way of describing a data type and is used by the browser to decide how to display data.

+

Value range:

+

See What Is Content-Type (MIME)? (Python SDK)

+

Default value:

+

If you do not specify contentType when uploading an object, the SDK determines the object type based on the suffix of the specified object name and automatically assigns a value to contentType.

+

contentLength

+

int

+

No

+

Explanation:

+

Size of the object to be uploaded

+

Restrictions:

+
  • The object size in a single upload ranges from 0 to 5 GB.
  • To upload files larger than 5 GB, multipart uploads should be used.
+

Default value:

+

If this parameter is not specified, OBS SDK for Python automatically calculates the size of the object.

+

sseHeader

+

SseCHeader

+

or

+

SseKmsHeader

+

No

+

Explanation:

+

Server-side encryption header

+

Default value:

+

None

+

storageClass

+

str

+

No

+

Explanation:

+

Storage class of the object

+

Value range:

+

See Table 4.

+

Default value:

+

None

+

successActionRedirect

+

str

+

No

+

Explanation:

+

Address (URL) to which a successfully answered request is redirected

+
  • If the value is valid and the request is successful, OBS returns status code 303. Location in the returned results contains SuccessActionRedirect as well as the bucket name, object name, and object ETag.
  • If the value is invalid, OBS ignores this parameter. In such case, Location in the returned results indicates the object address, and OBS returns a status code based on whether the operation succeeds or fails.
+

Default value:

+

None

+

extensionGrants

+

list of ExtensionGrant

+

No

+

Explanation:

+

List of the extended permissions for the object to be uploaded

+

Value range:

+

See Table 7.

+

Default value:

+

None

+

expires

+

int

+

No

+

Explanation:

+

Expiration time of the object (calculated from the latest modification time of the object). Expired objects are automatically deleted.

+

Restrictions:

+

This parameter can be configured only when uploading the object. It cannot be modified by calling a metadata modification API.

+

Value range:

+

An integer greater than or equal to 0, in days

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 HeadPermission

Constant

+

Default Value

+

Description

+

HeadPermission.PRIVATE

+

private

+

Private read/write

+

A bucket or object can only be accessed by its owner.

+

HeadPermission.PUBLIC_READ

+

public-read

+

Public read and private write

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, metadata, and object versions in the bucket.

+

If it is granted on an object, anyone can read the content and metadata of the object.

+

HeadPermission.PUBLIC_READ_WRITE

+

public-read-write

+

Public read/write

+

If this permission is granted on a bucket, anyone can read the object list, multipart tasks, metadata, and object versions in the bucket, and can upload or delete objects, initiate multipart upload tasks, upload parts, assemble parts, copy parts, and abort multipart upload tasks.

+

If it is granted on an object, anyone can read the content and metadata of the object.

+

HeadPermission.PUBLIC_READ_DELIVERED

+

public-read-delivered

+

Public read on a bucket as well as objects in the bucket

+

If this permission is granted on a bucket, anyone can read the object list, multipart tasks, metadata, and object versions, and read the content and metadata of objects in the bucket.

+
NOTE:

PUBLIC_READ_DELIVERED cannot be applied to objects.

+
+

HeadPermission.PUBLIC_READ_WRITE_DELIVERED

+

public-read-write-delivered

+

Public read/write on a bucket as well as objects in the bucket

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, metadata, and object versions in the bucket, and can upload or delete objects, initiate multipart upload tasks, upload parts, assemble parts, copy parts, and abort multipart uploads. They can also read the content and metadata of objects in the bucket.

+
NOTE:

PUBLIC_READ_WRITE_DELIVERED cannot be applied to objects.

+
+

HeadPermission.BUCKET_OWNER_FULL_CONTROL

+

public-read-write-delivered

+

If this permission is granted on an object, only the bucket and object owners have the full control over the object. By default, if you upload an object to a bucket of any other user, the bucket owner does not have the permissions on your object. After you grant this policy to the bucket owner, the bucket owner can have full control over your object.

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 4 StorageClass

Parameter

+

Type

+

Description

+

STANDARD

+

Standard storage class

+

Explanation:

+

Features low access latency and high throughput and is used for storing massive, frequently accessed (multiple times a month) or small objects (< 1 MB) requiring quick response.

+

WARM

+

Warm storage class

+

Explanation:

+

Used for storing data that is semi-frequently accessed (fewer than 12 times a year) but is instantly available when needed.

+

COLD

+

Cold storage class

+

Explanation:

+

Used for storing rarely accessed (once a year) data.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 5 SseCHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

encryption

+

str

+

Yes

+

Explanation:

+

SSE-C used for encrypting objects

+

Value range:

+

AES256

+

Default value:

+

None

+

key

+

str

+

Yes

+

Explanation:

+

Key used in SSE-C encryption. It corresponds to the encryption method. For example, if encryption is set to AES256, the key is calculated using the AES-256 algorithm.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 6 SseKmsHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

encryption

+

str

+

Yes

+

Explanation:

+

SSE-KMS used for encrypting objects

+

Value range:

+

kms

+

Default value:

+

None

+

key

+

str

+

No

+

Explanation:

+

Master key used in SSE-KMS

+

Value range:

+

The following two formats are supported:

+
  • regionID:domainID:key/key_id
  • key_id
+

In the preceding formats:

+ +

Default value:

+
  • If this parameter is not specified, the default master key will be used.
  • If there is no such a default master key, OBS will create one and use it by default.
+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 7 ExtensionGrant

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

granteeId

+

str

+

No

+

Explanation:

+

Account (domain) ID of the grantee

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and IAM User ID? (SDK for Python)

+

Default value:

+

None

+

permission

+

str

+

No

+

Explanation:

+

Granted permissions

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
Table 8 Permission

Constant

+

Description

+

READ

+

Read permission

+

A grantee with this permission for a bucket can obtain the list of objects, multipart uploads, bucket metadata, and object versions in the bucket.

+

A grantee with this permission for an object can obtain the object content and metadata.

+

WRITE

+

Write permission

+

A grantee with this permission for a bucket can upload, overwrite, and delete any object or part in the bucket.

+

Such permission for an object is not applicable.

+

READ_ACP

+

Permission to read ACL configurations

+

A grantee with this permission can obtain the ACL of a bucket or object.

+

A bucket or object owner has this permission for the bucket or object permanently.

+

WRITE_ACP

+

Permission to modify ACL configurations

+

A grantee with this permission can update the ACL of a bucket or object.

+

A bucket or object owner has this permission for the bucket or object permanently.

+

A grantee with this permission can modify the access control policy and thus the grantee obtains full access permissions.

+

FULL_CONTROL

+

Full control access, including read and write permissions for a bucket and its ACL, or for an object and its ACL.

+

A grantee with this permission for a bucket has READ, WRITE, READ_ACP, and WRITE_ACP permissions for the bucket.

+

A grantee with this permission for an object has READ, READ_ACP, and WRITE_ACP permissions for the object.

+
+
+

Responses

+
+ + + + + + + +
Table 9 List of returned results

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 10 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + +
Table 11 GetResult.body

GetResult.body Type

+

Description

+

PutContentResponse

+

Explanation:

+

Response to the request for uploading an object. For details, see Table 12.

+

Default value:

+

None

+
+
+

If file_path is a folder, the returned result is a GetResult list.

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 12 PutContentResponse

Parameter

+

Type

+

Description

+

storageClass

+

str

+

Explanation:

+

Storage class of the object

+

Value range:

+
  • If the storage class is Standard, leave this parameter blank.
  • For details about the available storage classes, see Table 4.
+

Default value:

+

None

+

versionId

+

str

+

Explanation:

+

Object version ID. If versioning is enabled for the bucket, the object version ID will be returned.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

etag

+

str

+

Explanation:

+

ETag of an object, which is a base64-encoded 128-bit MD5 digest. ETag is the unique identifier of the object content. It can be used to determine whether the object content is changed. For example, if the ETag is A when an object is uploaded and is B when the object is downloaded, the object content is changed. The ETag reflects changes only to the contents of the object, not its metadata. An uploaded object or copied object has a unique ETag.

+

Restrictions:

+

If an object is encrypted using server-side encryption, the ETag is not the MD5 value of the object.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

sseKms

+

str

+

Explanation:

+

SSE-KMS algorithm

+

Value range:

+

kms

+

Default value:

+

None

+

sseKmsKey

+

str

+

Explanation:

+

ID of the KMS master key when SSE-KMS is used

+

Value range:

+

Valid value formats are as follows:

+
  1. regionID:domainID:key/key_id
  2. key_id
+

In the preceding formats:

+ +

Default value:

+
  • If this parameter is not specified, the default master key will be used.
  • If there is no such a default master key, the system will create one and use it by default.
+

sseC

+

str

+

Explanation:

+

SSE-C algorithm

+

Value range:

+

AES256

+

Default value:

+

None

+

sseCKeyMd5

+

str

+

Explanation:

+

MD5 value of the key for encrypting objects when SSE-C is used. This value is used to check whether any error occurs during the transmission of the key.

+

Restrictions:

+

The value is encrypted by MD5 and then encoded by Base64, for example, 4XvB3tbNTN+tIEVa0/fGaQ==.

+

Default value:

+

None

+

objectUrl

+

str

+

Explanation:

+

Full path to the object

+

Default value:

+

None

+
+
+
+
+

Code Example 1: Uploading a Single File

This example uploads a single file.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
from obs import ObsClient
+from obs import PutObjectHeader
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+# Before running the sample code, ensure that the environment variables AccessKeyID and SecretAccessKey have been configured.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    # Specify the additional headers of the request for uploading an object.
+    headers = PutObjectHeader()
+    # (Optional) Specify the MIME type of the object.
+    headers.contentType = 'text/plain'
+    bucketName = "examplebucket"
+    # Specify an object name (the name displayed after the file is uploaded to the bucket).
+    objectKey = "objectname"
+    # Specify the full path of the file to be uploaded, for example, aa/bb.txt.
+    file_path = 'localfile'
+    # Specify the custom metadata of the object.
+    metadata = {'meta1': 'value1', 'meta2': 'value2'}
+    # Perform the file-based upload.
+    resp = obsClient.putFile(bucketName, objectKey, file_path, metadata, headers)
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Put File Succeeded')
+        print('requestId:', resp.requestId)
+        print('etag:', resp.body.etag)
+        print('versionId:', resp.body.versionId)
+        print('storageClass:', resp.body.storageClass)
+    else:
+        print('Put File Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Put File Failed')
+    print(traceback.format_exc())
+
+
+
+

Code Example 2: Uploading a Folder

This example uploads all files in a folder. The putFile method does not support concurrent uploads. If you need to upload all files in a folder concurrently for better performance, see Code Example 3.
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+# Before running the sample code, ensure that the environment variables AccessKeyID and SecretAccessKey have been configured.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+
+def out_put_res(resp, objectKey=None):
+    if isinstance(resp, list):
+        for res in resp:
+            out_put_res(res)
+    elif isinstance(resp, tuple) and isinstance(resp[1], list):
+        out_put_res(resp[1])
+    elif isinstance(resp, tuple):
+        if resp[1].status < 300:
+            print(f'Put File Succeeded, objectkey: {resp[0]}')
+        else:
+            print(f'Put File Failed, objectkey: {resp[0]}')
+            print('requestId:', resp[1].requestId)
+            print('errorCode:', resp[1].errorCode)
+            print('errorMessage:', resp[1].errorMessage)
+    else:
+        if resp.status < 300:
+            print(f'Put File Succeeded, objectkey: {objectKey}')
+        else:
+            print(f'Put File Failed, objectkey: {objectKey}')
+            print('requestId:', resp.requestId)
+            print('errorCode:', resp.errorCode)
+            print('errorMessage:', resp.errorMessage)
+try:
+    bucketName = "examplebucket"
+    # Specify a name for the uploaded folder. All files in the local folder are uploaded to this folder. Its name cannot end with a slash (/).
+    objectKey = "folder"
+    # Specify the full path of the folder to be uploaded, for example, aa/.
+    folder_path = 'localfolder/'
+    # Upload the folder.
+    resp = obsClient.putFile(bucketName, objectKey, folder_path)
+    # resp is a list of upload results of each file in the folder.
+    out_put_res(resp, objectKey)
+except:
+    print('Put File Failed')
+    print(traceback.format_exc())
+
+
+
+
+

Code Example 3: Uploading the Files in a Folder Concurrently

This example uploads all files in a folder concurrently.
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
from obs import ObsClient
+from concurrent.futures import ThreadPoolExecutor, as_completed
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+# Before running the sample code, ensure that the environment variables AccessKeyID and SecretAccessKey have been configured.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+folder_path = 'localfolder/'
+bucketName = 'examplebucket'
+# Specify a name for the uploaded folder. All files in the local folder are uploaded to this folder. Its name must end with a slash (/). If you want to upload files to the root directory, enter an empty string for the prefix, that is, prefix = ''.
+prefix = 'testobs/'
+ThreadNum = 20
+g = os.walk(folder_path)
+# Create a thread pool for upload.
+pool = ThreadPoolExecutor(ThreadNum)
+all_task = []
+for path, dir_list, file_list in g:
+    for file_name in file_list:
+        srcKey = os.path.join(path, file_name)
+        obsObjectKey = prefix + srcKey.split(folder_path)[1].replace('\\', '/')
+        exists = False
+        try:
+            # (Optional) Check whether the file already exists on OBS based on the object name.
+            # resp = obsClient.headObject(bucketName, obsObjectKey)
+            # if resp.status < 300:
+            #     exists = True
+            # elif resp.status == 404:
+            #     exists = False
+            # else:
+            #     print('Error happened, reupload it.')
+            if not exists:
+                print("File %s not exists in obs, upload it", srcKey)
+                all_task.append(pool.submit(obsClient.putFile, bucketName, obsObjectKey, srcKey))
+                # You are advised to use obsClient.uploadFile to upload large files. For details about the parameters, see the section about the API for resumable upload.
+                # partSize = 9 * 1024 * 1024
+                # taskNum = 10
+                # enableCheckpoint = True
+                # all_task.append(pool.submit(obsClient.uploadFile, bucketName, obsObjectKey, srcKey, partSize, taskNum, enableCheckpoint))
+        except:
+            print(traceback.format_exc())
+for future in as_completed(all_task):
+    put_resp = future.result()
+    if put_resp.status < 300:
+        print(f'Put File Succeeded, objectUrl: {put_resp.body.objectUrl}')
+    else:
+        print('Put File Failed')
+        print('requestId:', put_resp.requestId)
+        print('errorCode:', put_resp.errorCode)
+        print('errorMessage:', put_resp.errorMessage)
+
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0904.html b/docs/obs_3rd_party/python_sdk/obs_22_0904.html new file mode 100644 index 000000000..98655d3d7 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0904.html @@ -0,0 +1,1025 @@ + + +

Uploading an Object - Append (SDK for Python)

+

Function

This API uploads a file or folder to an existing OBS bucket. These files can be texts, images, videos, or any other type of files.

+

The AppendObject operation adds data to the end of an object in a specified bucket. If there is no object with the same key values in the bucket, a new object is created.

+
+

Restrictions

+
+

Method

ObsClient.appendObject(bucketName, objectKey, content, metadata, headers, progressCallback, autoClose, extensionHeaders)
+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

str

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

content

+

AppendObjectContent

+

Yes

+

Explanation:

+

Content to be appended

+

Value range:

+

See Table 2.

+

Default value:

+

None

+

metadata

+

dict

+

No

+

Explanation:

+

Custom metadata to be appended. You can add a header starting with x-obs-meta- in the request to define metadata. The custom metadata will be returned in the response when you retrieve the object or query the object metadata.

+

Restrictions:

+
  • This parameter is valid only for the first append upload.
  • The custom metadata cannot exceed 8 KB. To measure the custom metadata, sum the number of bytes in the UTF-8 encoding of each key and value.
  • The custom metadata keys are case insensitive, but are stored in lowercase in OBS. The key values are case sensitive.
  • Both custom metadata keys and their values must conform to US-ASCII standards. If non-ASCII or unrecognizable characters are required, they must be encoded and decoded in URL or Base64 on the client, because the server does not perform such operations.
+

Default value:

+

None

+

headers

+

AppendObjectHeader

+

No

+

Explanation:

+

Headers in the request used for configuring the storage class, redundancy policy, and other basic information about the object

+

Restrictions:

+

This parameter is valid only for the first append upload.

+

Value range:

+

See Table 3.

+

Default value:

+

None

+

progressCallback

+

callable

+

No

+

Explanation:

+

Callback function for obtaining the upload progress

+

Default value:

+

None

+
NOTE:

This function contains the following parameters in sequence: number of uploaded bytes, total number of bytes, and used time (in seconds). For details about the sample code, see Obtaining the Upload Progress (SDK for Python).

+
+

autoClose

+

bool

+

No

+

Explanation:

+

Whether or not to automatically close data streams after the upload is complete

+

Value range:

+

True: The data stream is automatically closed.

+

False: The data stream is not automatically closed.

+

Default value:

+

True

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 AppendObjectContent

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

content

+

str

+

or

+

readable object

+

No

+

Explanation:

+

Content to be appended

+

Value range:

+
  • A character string of object content
  • Readable object
  • Path of the file to be uploaded (isFile must be set to True.)
+
NOTE:

If content is a readable object that contains the read attribute, data can be read from content. Otherwise, the object content is a character string.

+
+

Default value:

+

None

+

position

+

int

+

or

+

str

+

Yes

+

Explanation:

+

Position where the object data is appended

+

Restrictions:

+

For an object to be appended, the value of position must be set to 0 when the object is uploaded for the first time. For the second append upload, the value of position should be set to the value of nextPosition returned in the response when the first upload is successful.

+

Value range:

+

An integer greater than or equal to 0, in bytes

+

Default value:

+

0

+

offset

+

int

+

or

+

str

+

No

+

Explanation:

+

Offset, in bytes. This parameter is required if the content for an append upload is a local file.

+

Value range:

+

An integer greater than or equal to 0, in bytes

+

Default value:

+

0

+

isFile

+

bool

+

No

+

Explanation:

+

Whether content indicates the file path.

+

Value range:

+

True: content indicates the file path.

+

False: content does not indicate the file path.

+

Default value:

+

False

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 AppendObjectHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

md5

+

str

+

No

+

Explanation:

+

Base64-encoded MD5 value of the content to be appended. It is used for the OBS server to verify data integrity.

+

Value range:

+

Base64-encoded 128-bit MD5 value of the request body calculated according to RFC 1864

+

Example: n58IG6hfM7vqI4K0vnWpog==

+

Default value:

+

None

+

acl

+

str

+

No

+

Explanation:

+

Pre-defined access control policies, which can be specified in the append upload request.

+

Restrictions:

+

This parameter can only be configured in the first request for append upload. The configurations specified in the first request will be used in subsequent requests by default.

+

Value range:

+

See Table 4.

+

Default value:

+

None

+

location

+

str

+

No

+

Explanation:

+

If the bucket is configured with website hosting, the request for obtaining the object can be redirected to another object in the bucket or an external URL.

+

The request is redirected to object anotherPage.html in the same bucket:

+

location:/anotherPage.html

+

The request is redirected to an external URL http://www.example.com/:

+

location:http://www.example.com/

+

OBS obtains the specified value from the header and stores it in the object metadata location.

+

Restrictions:

+
  • This parameter can only be configured in the first request for append upload. The configurations specified in the first request will be used in subsequent requests by default.
  • The value must start with a slash (/), http://, or https:// and cannot exceed 2 KB.
  • OBS only supports redirection for objects in the root directory of a bucket.
+

Default value:

+

None

+

contentType

+

str

+

No

+

Explanation:

+

MIME type of the object specified in the first append upload MIME type is a standard way of describing a data type and is used by the browser to decide how to display data.

+

Value range:

+

See What Is Content-Type (MIME)? (Python SDK)

+

Restrictions:

+

This parameter can only be configured in the first request for append upload. The configurations specified in the first request will be used in subsequent requests by default.

+

Default value:

+

If you do not specify contentType when uploading an object, the SDK determines the object type based on the suffix of the specified object name and automatically assigns a value to contentType.

+

contentLength

+

int

+

No

+

Explanation:

+

Length of the content to be appended

+

Restrictions:

+
  • The object size in a single upload ranges from 0 to 5 GB.
  • To upload files larger than 5 GB, multipart uploads should be used.
+

Default value:

+

If this parameter is not specified, OBS SDK for Python automatically calculates the size of the object.

+

sseHeader

+

SseCHeader

+

or

+

SseKmsHeader

+

No

+

Explanation:

+

Server-side encryption header

+

Restrictions:

+

This parameter can only be configured in the first request for append upload. The configurations specified in the first request will be used in subsequent requests by default.

+

Default value:

+

None

+

storageClass

+

str

+

No

+

Explanation:

+

Storage class of the object that can be specified in the append upload request

+

Restrictions:

+

This parameter can only be configured in the first request for append upload. The configurations specified in the first request will be used in subsequent requests by default.

+

Value range:

+
  • If the storage class is Standard, leave this parameter blank.
  • For details about the available storage classes, see Table 5.
+

Default value:

+

None

+

successActionRedirect

+

str

+

No

+

Explanation:

+

Address (URL) to which a successfully answered request is redirected

+
  • If the value is valid and the request is successful, OBS returns status code 303. Location in the returned results contains SuccessActionRedirect as well as the bucket name, object name, and object ETag.
  • If the value is invalid, OBS ignores this parameter. In such case, Location in the returned results indicates the object address, and OBS returns a status code based on whether the operation succeeds or fails.
+

Default value:

+

None

+

extensionGrants

+

list of ExtensionGrant

+

No

+

Explanation:

+

List of extension permissions that can be specified in the append upload request

+

Restrictions:

+

This parameter can only be configured in the first request for append upload. The configurations specified in the first request will be used in subsequent requests by default.

+

Value range:

+

See Table 8.

+

Default value:

+

The value specified in the first append upload request

+

expires

+

int

+

No

+

Explanation:

+

Lifecycle (starting from the last modification time of the object) that can be specified in the append upload request. Once the object expires, it is automatically deleted.

+

Restrictions:

+
  • This parameter can only be configured in the first request for append upload. The configurations specified in the first request will be used in subsequent requests by default.
  • This parameter can be configured only when uploading the object. It cannot be modified by calling a metadata modification API.
+

Value range:

+

An integer greater than or equal to 0, in days

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 4 HeadPermission

Constant

+

Default Value

+

Description

+

HeadPermission.PRIVATE

+

private

+

Private read/write

+

A bucket or object can only be accessed by its owner.

+

HeadPermission.PUBLIC_READ

+

public-read

+

Public read and private write

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, metadata, and object versions in the bucket.

+

If it is granted on an object, anyone can read the content and metadata of the object.

+

HeadPermission.PUBLIC_READ_WRITE

+

public-read-write

+

Public read/write

+

If this permission is granted on a bucket, anyone can read the object list, multipart tasks, metadata, and object versions in the bucket, and can upload or delete objects, initiate multipart upload tasks, upload parts, assemble parts, copy parts, and abort multipart upload tasks.

+

If it is granted on an object, anyone can read the content and metadata of the object.

+

HeadPermission.PUBLIC_READ_DELIVERED

+

public-read-delivered

+

Public read on a bucket as well as objects in the bucket

+

If this permission is granted on a bucket, anyone can read the object list, multipart tasks, metadata, and object versions, and read the content and metadata of objects in the bucket.

+
NOTE:

PUBLIC_READ_DELIVERED cannot be applied to objects.

+
+

HeadPermission.PUBLIC_READ_WRITE_DELIVERED

+

public-read-write-delivered

+

Public read/write on a bucket as well as objects in the bucket

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, metadata, and object versions in the bucket, and can upload or delete objects, initiate multipart upload tasks, upload parts, assemble parts, copy parts, and abort multipart uploads. They can also read the content and metadata of objects in the bucket.

+
NOTE:

PUBLIC_READ_WRITE_DELIVERED cannot be applied to objects.

+
+

HeadPermission.BUCKET_OWNER_FULL_CONTROL

+

public-read-write-delivered

+

If this permission is granted on an object, only the bucket and object owners have the full control over the object. By default, if you upload an object to a bucket of any other user, the bucket owner does not have the permissions on your object. After you grant this policy to the bucket owner, the bucket owner can have full control over your object.

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 5 StorageClass

Parameter

+

Type

+

Description

+

STANDARD

+

Standard storage class

+

Explanation:

+

Features low access latency and high throughput and is used for storing massive, frequently accessed (multiple times a month) or small objects (< 1 MB) requiring quick response.

+

WARM

+

Warm storage class

+

Explanation:

+

Used for storing data that is semi-frequently accessed (fewer than 12 times a year) but is instantly available when needed.

+

COLD

+

Cold storage class

+

Explanation:

+

Used for storing rarely accessed (once a year) data.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 6 SseCHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

encryption

+

str

+

Yes

+

Explanation:

+

SSE-C used for encrypting objects

+

Value range:

+

AES256

+

Default value:

+

None

+

key

+

str

+

Yes

+

Explanation:

+

Key used in SSE-C encryption. It corresponds to the encryption method. For example, if encryption is set to AES256, the key is calculated using the AES-256 algorithm.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 7 SseKmsHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

encryption

+

str

+

Yes

+

Explanation:

+

SSE-KMS used for encrypting objects

+

Value range:

+

kms

+

Default value:

+

None

+

key

+

str

+

No

+

Explanation:

+

Master key used in SSE-KMS

+

Value range:

+

The following two formats are supported:

+
  • regionID:domainID:key/key_id
  • key_id
+

In the preceding formats:

+ +

Default value:

+
  • If this parameter is not specified, the default master key will be used.
  • If there is no such a default master key, OBS will create one and use it by default.
+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 8 ExtensionGrant

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

granteeId

+

str

+

No

+

Explanation:

+

Account (domain) ID of the grantee

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and IAM User ID? (SDK for Python)

+

Default value:

+

None

+

permission

+

str

+

No

+

Explanation:

+

Granted permissions

+

Default value:

+

None

+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
Table 9 Permission

Constant

+

Description

+

READ

+

Read permission

+

A grantee with this permission for a bucket can obtain the list of objects, multipart uploads, bucket metadata, and object versions in the bucket.

+

A grantee with this permission for an object can obtain the object content and metadata.

+

WRITE

+

Write permission

+

A grantee with this permission for a bucket can upload, overwrite, and delete any object or part in the bucket.

+

Such permission for an object is not applicable.

+

READ_ACP

+

Permission to read ACL configurations

+

A grantee with this permission can obtain the ACL of a bucket or object.

+

A bucket or object owner has this permission for the bucket or object permanently.

+

WRITE_ACP

+

Permission to modify ACL configurations

+

A grantee with this permission can update the ACL of a bucket or object.

+

A bucket or object owner has this permission for the bucket or object permanently.

+

A grantee with this permission can modify the access control policy and thus the grantee obtains full access permissions.

+

FULL_CONTROL

+

Full control access, including read and write permissions for a bucket and its ACL, or for an object and its ACL.

+

A grantee with this permission for a bucket has READ, WRITE, READ_ACP, and WRITE_ACP permissions for the bucket.

+

A grantee with this permission for an object has READ, READ_ACP, and WRITE_ACP permissions for the object.

+
+
+

Responses

+
+ + + + + + + +
Table 10 List of returned results

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 11 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + +
Table 12 GetResult.body

GetResult.body Type

+

Description

+

AppendObjectResponse

+

Explanation:

+

Response to the append upload request. For details, see Table 13.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 13 AppendObjectResponse

Parameter

+

Type

+

Description

+

storageClass

+

str

+

Explanation:

+

Object storage class.

+

Value range:

+
  • If the storage class is Standard, leave this parameter blank.
  • For details about the available storage classes, see Table 5.
+

Default value:

+

None

+

etag

+

str

+

Explanation:

+

ETag of an object, which is a base64-encoded 128-bit MD5 digest. ETag is the unique identifier of the object content. It can be used to determine whether the object content is changed. For example, if the ETag is A when an object is uploaded and is B when the object is downloaded, the object content is changed. The ETag reflects changes only to the contents of the object, not its metadata. An uploaded object or copied object has a unique ETag.

+

Restrictions:

+

If an object is encrypted using server-side encryption, the ETag is not the MD5 value of the object.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

nextPosition

+

int

+

Explanation:

+

Start position for next appending

+

Value range:

+

An integer greater than or equal to 0, in bytes

+

Default value:

+

None

+

sseKms

+

str

+

Explanation:

+

SSE-KMS algorithm

+

Value range:

+

kms

+

Default value:

+

None

+

sseKmsKey

+

str

+

Explanation:

+

ID of the KMS master key when SSE-KMS is used

+

Value range:

+

Valid value formats are as follows:

+
  1. regionID:domainID:key/key_id
  2. key_id
+

In the preceding formats:

+ +

Default value:

+
  • If this parameter is not specified, the default master key will be used.
  • If there is no such a default master key, the system will create one and use it by default.
+

sseC

+

str

+

Explanation:

+

SSE-C algorithm

+

Value range:

+

AES256

+

Default value:

+

None

+

sseCKeyMd5

+

str

+

Explanation:

+

MD5 value of the key for encrypting objects when SSE-C is used. This value is used to check whether any error occurs during the transmission of the key.

+

Restrictions:

+

The value is encrypted by MD5 and then encoded by Base64, for example, 4XvB3tbNTN+tIEVa0/fGaQ==.

+

Default value:

+

None

+

objectUrl

+

str

+

Explanation:

+

Full path to the object

+

Default value:

+

None

+
+
+
+

Code Examples

This example appends content to an object.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
from obs import ObsClient
+from obs import AppendObjectContent
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    # Specify the message body of the request for an append upload.
+    content = AppendObjectContent()
+    # Specify the content to be appended.
+    content.content = 'Hello OBS'
+    # Specify the starting position (byte 0 in this example) the content is appended to.
+    content.position = 0
+    # If you upload an object for the first time using the append upload, an error will be reported (status code 409) if an ordinary object with the same name already exists.
+    bucketName = "examplebucket"
+    # Specify the name of the object to append content to.
+    objectKey = "objectname"
+    # Append content to the object.
+    resp = obsClient.appendObject(bucketName, objectKey, content)
+
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Append Object Succeeded')
+        print('requestId:', resp.requestId)
+        print('nextPosition:', resp.body.nextPosition)
+    else:
+        print('Append Object Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Append Object Failed')   
+    print(traceback.format_exc())
+
+
+
  • Objects uploaded using ObsClient.putObject, referred to as common objects, can overwrite objects uploaded using ObsClient.appendObject, referred to as appendable objects. Data cannot be appended to an appendable object anymore once the object has been overwritten by a common object.
  • When you upload an object for the first time in appendable mode, an exception will be reported (HTTP status code 409) if a common object with the same name exists.
  • The ETag returned for the append upload is the ETag for the appended content, rather than that of the whole object.
  • Data appended each time can be up to 5 GB, and a maximum of 10,000 uploads can be appended for an object.
  • After an append upload is successful, you can obtain the location for the next append upload by using body.nextPosition in the returned results or call ObsClient.getObjectMetadata.
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0905.html b/docs/obs_3rd_party/python_sdk/obs_22_0905.html new file mode 100644 index 000000000..7943c1c32 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0905.html @@ -0,0 +1,979 @@ + + +

Uploading an Object - Resumable (SDK for Python)

+

Function

The resumable upload is an encapsulated and enhanced version of the multipart upload used for dealing with possible upload failures of large files when the network connection is unstable or a program crashes. This API splits the file into multiple parts and uploads them individually. The upload result of each part is recorded in a checkpoint file in real time. A success message is returned only when all parts are uploaded. If any parts fail, an error message is returned telling you to call the API again to upload the failed parts. Since the checkpoint file contains the progress of each part, it saves you uploading all parts again in the event of an error.

+
+

Restrictions

+
+

Method

ObsClient.uploadFile(bucketName, objectKey, uploadFile, partSize, taskNum, enableCheckpoint, checkpointFile, checkSum, metadata, progressCallback, headers, extensionHeaders)
+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Description

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

str

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

uploadFile

+

str

+

Yes

+

Explanation:

+

Complete path of the local file to be uploaded, for example, aa/bb.txt.

+

Default value:

+

None

+

partSize

+

int

+

No

+

Explanation:

+

Part size

+

Value range:

+

The value ranges from 100 KB to 5 GB, in bytes.

+

Default value:

+

9 MB

+

taskNum

+

int

+

No

+

Explanation:

+

Maximum number of parts that can be uploaded concurrently

+

Value range:

+

1~10000

+

Default value:

+

1, indicating concurrent uploads are not used.

+

enableCheckpoint

+

bool

+

No

+

Explanation:

+

Whether to enable the resumable upload mode

+

Value range:

+

True: The resumable upload mode is enabled.

+

False: The resumable upload mode is disabled.

+

Default value:

+

False

+

checkpointFile

+

str

+

No

+

Explanation:

+

Address of a file generated for recording the progress of a resumable upload. The file contains the information about parts and the upload progress.

+

Restrictions:

+

This parameter is valid only for resumable uploads.

+

Default value:

+

If this parameter is left blank, the progress file will be in the same directory as the local file to be uploaded.

+

checkSum

+

bool

+

No

+

Explanation:

+

Whether to verify the file to upload. If this parameter is enabled, before each task restarts, the system verifies whether the file to upload is the one used during task initialization.

+

Value range:

+

True: The file to upload is verified.

+

False: The file to upload is not verified.

+

Default value:

+

False

+

metadata

+

dict

+

No

+

Explanation:

+

Custom metadata of the object to be uploaded. You can add a header starting with x-obs-meta- in the request to define metadata. The custom metadata will be returned in the response when you retrieve the object or query the object metadata.

+

Restrictions:

+
  • The custom metadata cannot exceed 8 KB. To measure the custom metadata, sum the number of bytes in the UTF-8 encoding of each key and value.
  • The custom metadata keys are case insensitive, but are stored in lowercase in OBS. The key values are case sensitive.
  • Both custom metadata keys and their values must conform to US-ASCII standards. If non-ASCII or unrecognizable characters are required, they must be encoded and decoded in URL or Base64 on the client, because the server does not perform such operations.
+

Default value:

+

None

+

progressCallback

+

callable

+

No

+

Explanation:

+

Callback function for obtaining the upload progress

+

Default value:

+

None

+
NOTE:

This function contains the following parameters in sequence: number of uploaded bytes, total number of bytes, and used time (in seconds). For details about the sample code, see Obtaining the Upload Progress (SDK for Python).

+
+

headers

+

UploadFileHeader

+

No

+

Explanation:

+

Headers in the request used for configuring the storage class, redundancy policy, and other basic information about the object

+

Value range:

+

See Table 2.

+

Default value:

+

None

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 UploadFileHeader

Parameter

+

Type

+

Description

+

Description

+

acl

+

str

+

No

+

Explanation:

+

Pre-defined access policy specified during object creation.

+

Value range:

+

See Table 3.

+

Default value:

+

None

+

location

+

str

+

No

+

Explanation:

+

If the bucket is configured with website hosting, the request for obtaining the object can be redirected to another object in the bucket or an external URL.

+

The request is redirected to object anotherPage.html in the same bucket:

+

location:/anotherPage.html

+

The request is redirected to an external URL http://www.example.com/:

+

location:http://www.example.com/

+

OBS obtains the specified value from the header and stores it in the object metadata location.

+

Restrictions:

+
  • The value must start with a slash (/), http://, or https:// and cannot exceed 2 KB.
  • OBS only supports redirection for objects in the root directory of a bucket.
+

Default value:

+

None

+

contentType

+

str

+

No

+

Explanation:

+

MIME type of the file to be uploaded. MIME type is a standard way of describing a data type and is used by the browser to decide how to display data.

+

Value range:

+

See What Is Content-Type (MIME)? (Python SDK)

+

Default value:

+

If you do not specify contentType when uploading an object, the SDK determines the object type based on the suffix of the specified object name and automatically assigns a value to contentType.

+

sseHeader

+

SseCHeader

+

or

+

SseKmsHeader

+

No

+

Explanation:

+

Server-side encryption header

+

Default value:

+

None

+

storageClass

+

str

+

No

+

Explanation:

+

Storage class of the object

+

Value range:

+

For details about the available storage classes, see Table 4.

+

Default value:

+

None

+

successActionRedirect

+

str

+

No

+

Explanation:

+

Address (URL) to which a successfully answered request is redirected

+
  • If the value is valid and the request is successful, OBS returns status code 303. Location in the returned results contains SuccessActionRedirect as well as the bucket name, object name, and object ETag.
  • If the value is invalid, OBS ignores this parameter. In such case, Location in the returned results indicates the object address, and OBS returns a status code based on whether the operation succeeds or fails.
+

Default value:

+

None

+

extensionGrants

+

list of ExtensionGrant

+

No

+

Explanation:

+

List of the extended permissions for the object to be uploaded

+

Value range:

+

See Table 7.

+

Default value:

+

None

+

expires

+

int

+

No

+

Explanation:

+

Expiration time of the object (calculated from the latest modification time of the object). Expired objects are automatically deleted.

+

Restrictions:

+

This parameter can be configured only when uploading the object. It cannot be modified by calling a metadata modification API.

+

Value range:

+

An integer greater than or equal to 0, in days

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 HeadPermission

Constant

+

Default Value

+

Description

+

HeadPermission.PRIVATE

+

private

+

Private read/write

+

A bucket or object can only be accessed by its owner.

+

HeadPermission.PUBLIC_READ

+

public-read

+

Public read and private write

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, metadata, and object versions in the bucket.

+

If it is granted on an object, anyone can read the content and metadata of the object.

+

HeadPermission.PUBLIC_READ_WRITE

+

public-read-write

+

Public read/write

+

If this permission is granted on a bucket, anyone can read the object list, multipart tasks, metadata, and object versions in the bucket, and can upload or delete objects, initiate multipart upload tasks, upload parts, assemble parts, copy parts, and abort multipart upload tasks.

+

If it is granted on an object, anyone can read the content and metadata of the object.

+

HeadPermission.PUBLIC_READ_DELIVERED

+

public-read-delivered

+

Public read on a bucket as well as objects in the bucket

+

If this permission is granted on a bucket, anyone can read the object list, multipart tasks, metadata, and object versions, and read the content and metadata of objects in the bucket.

+
NOTE:

PUBLIC_READ_DELIVERED cannot be applied to objects.

+
+

HeadPermission.PUBLIC_READ_WRITE_DELIVERED

+

public-read-write-delivered

+

Public read/write on a bucket as well as objects in the bucket

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, metadata, and object versions in the bucket, and can upload or delete objects, initiate multipart upload tasks, upload parts, assemble parts, copy parts, and abort multipart uploads. They can also read the content and metadata of objects in the bucket.

+
NOTE:

PUBLIC_READ_WRITE_DELIVERED cannot be applied to objects.

+
+

HeadPermission.BUCKET_OWNER_FULL_CONTROL

+

public-read-write-delivered

+

If this permission is granted on an object, only the bucket and object owners have the full control over the object. By default, if you upload an object to a bucket of any other user, the bucket owner does not have the permissions on your object. After you grant this policy to the bucket owner, the bucket owner can have full control over your object.

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 4 StorageClass

Parameter

+

Type

+

Description

+

STANDARD

+

Standard storage class

+

Explanation:

+

Features low access latency and high throughput and is used for storing massive, frequently accessed (multiple times a month) or small objects (< 1 MB) requiring quick response.

+

WARM

+

Warm storage class

+

Explanation:

+

Used for storing data that is semi-frequently accessed (fewer than 12 times a year) but is instantly available when needed.

+

COLD

+

Cold storage class

+

Explanation:

+

Used for storing rarely accessed (once a year) data.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 5 SseCHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

encryption

+

str

+

Yes

+

Explanation:

+

SSE-C used for encrypting objects

+

Value range:

+

AES256

+

Default value:

+

None

+

key

+

str

+

Yes

+

Explanation:

+

Key used in SSE-C encryption. It corresponds to the encryption method. For example, if encryption is set to AES256, the key is calculated using the AES-256 algorithm.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 6 SseKmsHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

encryption

+

str

+

Yes

+

Explanation:

+

SSE-KMS used for encrypting objects

+

Value range:

+

kms

+

Default value:

+

None

+

key

+

str

+

No

+

Explanation:

+

Master key used in SSE-KMS

+

Value range:

+

The following two formats are supported:

+
  • regionID:domainID:key/key_id
  • key_id
+

In the preceding formats:

+ +

Default value:

+
  • If this parameter is not specified, the default master key will be used.
  • If there is no such a default master key, OBS will create one and use it by default.
+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 7 ExtensionGrant

Parameter

+

Type

+

Description

+

Description

+

granteeId

+

str

+

No

+

Explanation:

+

Account (domain) ID of the grantee

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and IAM User ID? (SDK for Python)

+

Default value:

+

None

+

permission

+

str

+

No

+

Explanation:

+

Granted permissions

+

Default value:

+

None

+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
Table 8 Permission

Constant

+

Description

+

READ

+

Read permission

+

A grantee with this permission for a bucket can obtain the list of objects, multipart uploads, bucket metadata, and object versions in the bucket.

+

A grantee with this permission for an object can obtain the object content and metadata.

+

WRITE

+

Write permission

+

A grantee with this permission for a bucket can upload, overwrite, and delete any object or part in the bucket.

+

Such permission for an object is not applicable.

+

READ_ACP

+

Permission to read ACL configurations

+

A grantee with this permission can obtain the ACL of a bucket or object.

+

A bucket or object owner has this permission for the bucket or object permanently.

+

WRITE_ACP

+

Permission to modify ACL configurations

+

A grantee with this permission can update the ACL of a bucket or object.

+

A bucket or object owner has this permission for the bucket or object permanently.

+

A grantee with this permission can modify the access control policy and thus the grantee obtains full access permissions.

+

FULL_CONTROL

+

Full control access, including read and write permissions for a bucket and its ACL, or for an object and its ACL.

+

A grantee with this permission for a bucket has READ, WRITE, READ_ACP, and WRITE_ACP permissions for the bucket.

+

A grantee with this permission for an object has READ, READ_ACP, and WRITE_ACP permissions for the object.

+
+
+

Responses

+
+ + + + + + + +
Table 9 List of returned results

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 10 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + +
Table 11 GetResult.body

GetResult.body Type

+

Description

+

CompleteMultipartUploadResponse

+

Explanation:

+

Response to the part assembling. For details, see Table 12.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 12 CompleteMultipartUploadResponse

Parameter

+

Type

+

Description

+

etag

+

str

+

Explanation:

+

The ETag that uniquely identifies the object after its parts were assembled, calculated based on the ETag of each part.

+

Restrictions:

+

If an object is encrypted using server-side encryption, the ETag is not the MD5 value of the object.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

bucket

+

str

+

Explanation:

+

Bucket in which parts are assembled

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

key

+

str

+

Explanation:

+

Object name obtained after part assembling.

+

An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

location

+

str

+

Explanation:

+

URL of the generated object after part assembling

+

Default value:

+

None

+

versionId

+

str

+

Explanation:

+

Version ID of the object obtained after part assembling

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

sseKms

+

str

+

Explanation:

+

SSE-KMS algorithm

+

Value range:

+

kms

+

Default value:

+

None

+

sseKmsKey

+

str

+

Explanation:

+

ID of the KMS master key when SSE-KMS is used

+

Value range:

+

Valid value formats are as follows:

+
  1. regionID:domainID:key/key_id
  2. key_id
+

In the preceding formats:

+ +

Default value:

+
  • If this parameter is not specified, the default master key will be used.
  • If there is no such a default master key, OBS will create one and use it by default.
+

sseC

+

str

+

Explanation:

+

SSE-C algorithm

+

Value range:

+

AES256

+

Default value:

+

None

+

sseCKeyMd5

+

str

+

Explanation:

+

MD5 value of the key for encrypting objects when SSE-C is used. This value is used to check whether any error occurs during the transmission of the key.

+

Restrictions:

+

The value is encrypted by MD5 and then encoded by Base64, for example, 4XvB3tbNTN+tIEVa0/fGaQ==.

+

Default value:

+

None

+

objectUrl

+

str

+

Explanation:

+

Full path to the obtained object after part assembling

+

Default value:

+

None

+
+
+
+

Code Examples

This example uploads object localfile to bucket examplebucket using resumable upload.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+
+try:
+    bucketName = "examplebucket"
+    # Specify an object name (the name displayed after the file is uploaded to the bucket).
+    objectKey = "objectname"
+    # Specify the path of the file to be uploaded.
+    uploadFile = 'localfile'
+    # Specify the number of parts that can be concurrently uploaded.
+    taskNum = 5
+    # Specify the part size, in bytes. 10 MB is used as an example.
+    partSize = 10 * 1024 * 1024
+    # Enable the resumable upload by setting enableCheckpoint to True.
+    enableCheckpoint = True
+    # Upload the object using resumable upload.
+    resp = obsClient.uploadFile(bucketName, objectKey, uploadFile, partSize, taskNum, enableCheckpoint, encoding_type='url')
+
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Upload File Succeeded')
+        print('requestId:', resp.requestId)
+    else:
+        print('Upload File Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Upload File Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0906.html b/docs/obs_3rd_party/python_sdk/obs_22_0906.html new file mode 100644 index 000000000..9bfbce2ac --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0906.html @@ -0,0 +1,108 @@ + + +

Obtaining the Upload Progress (SDK for Python)

+

You can query the upload progress when uploading an object in streaming, file-based, multipart, appendable, or resumable mode.

+

This example configures a callback function to obtain the object upload progress.

+

Sample code is as follows:

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+
+# Obtain the upload progress.
+def callback(transferredAmount, totalAmount, totalSeconds):
+    # Obtain the average upload rate (KB/s).
+    print(transferredAmount * 1.0 / totalSeconds / 1024)
+    # Obtain the upload progress in percentage.
+    print(transferredAmount * 100.0 / totalAmount)
+
+try:
+    bucketName = "examplebucket"
+    # Specify an object name (the name displayed after the file is uploaded to the bucket).
+    objectKey = "objectname"
+    # Specify the full path of the file to be uploaded, for example, aa/bb.txt.
+    file_path = 'localfile'
+    # Perform the file-based upload.
+    resp = obsClient.putFile(bucketName, objectKey, file_path, progressCallback=callback)
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Put File Succeeded')
+        print('requestId:', resp.requestId)
+        print('etag:', resp.body.etag)
+        print('versionId:', resp.body.versionId)
+        print('storageClass:', resp.body.storageClass)
+    else:
+        print('Put File Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Put File Failed')
+    print(traceback.format_exc())
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0907.html b/docs/obs_3rd_party/python_sdk/obs_22_0907.html new file mode 100644 index 000000000..6e9a1f6b8 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0907.html @@ -0,0 +1,278 @@ + + +

Uploading an Object - Browser-Based (SDK for Python)

+

Function

This API uploads an object up to 5 GB to a specified bucket in HTML form. You can call ObsClient.createPostSignature to generate parameters for requesting a browser-based upload. For details, see the following:

+
  1. Call ObsClient.createPostSignature to generate request parameters for authentication.
  2. Prepare an HTML form.
  3. Enter the request parameters in the page.
  4. Select a local file and upload it in browser-based mode.
+

There are two request parameters generated for authentication:

+
  • policy, which corresponds to the policy parameter in the form.
  • signature, which corresponds to the signature parameter in the form.
+
+
+

Restrictions

+ +
+

Method

ObsClient.createPostSignature(bucketName, objectKey, expires, formParams)
+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

No

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

str

+

No

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

expires

+

int

+

No

+

Explanation:

+

Expiration time of authentication for a browser-based upload

+

Value range:

+

A positive integer, in seconds

+

Default value:

+

300

+

formParams

+

dict

+

No

+

Explanation:

+

Parameters of browser-based uploads, not including key, policy, and signature.

+

Value range:

+

(When you use the following parameters, you must add the x-obs prefix to them. Taking acl as an example, it should be configured as formParams['x-obs-acl']='public-read'. To obtain the values of these parameters, see the response header descriptions in APIs.)

+
  • acl
  • cache-control
  • content-type
  • content-disposition
  • content-encoding
  • expires
+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + +
Table 2 List of returned results

Parameter

+

Type

+

Description

+

originPolicy

+

str

+

Explanation:

+

Value of Policy that is not encoded by Base64. This parameter can only be used for verification. For example:

+

{"expiration":"2023-09-12T12:52:59Z","conditions":[{"content-type":"text/plain"},{"bucket":"examplebucket"},{"key":"example/objectname"},]}"

+

Default value:

+

None

+

policy

+

str

+

Explanation:

+

Value of Policy that is encoded by Base64. For example:

+

eyJleHBpcmF0aW9uIjoiMjAyMy0wOS0xMlQxMjo1Mjo1OVoiLCJjb25kaXRpb25zIjpbeyJjb250ZW50LXR5cGUiOiJ0ZXh0L3BsYWluIn0seyJidWNrZXQiOiJleGFtcGxlYnVja2V0In0seyJrZXkiOiJleGFtcGxlL29iamVjdG5hbWUifSxdfQ==

+

Default value:

+

None

+

signature

+

str

+

Explanation:

+

signature in the form For example:

+

g0jQr4v9VWd1Q2FOFDG6LGfV9Cw=

+

Default value:

+

None

+
+
+
+

Code Examples

This example generates authentication parameters policy and signature for a browser-based upload.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName = "examplebucket"
+    objectKey = "objectname"
+    # Configure the validity period (in seconds) for a browser-based upload request. 3600 is used as an example.
+    expires = 3600
+    # Specify parameters for a browser-based upload except key, policy, and signature. In this example, x-obs-acl is set to private and content-type is set to text/plain.
+    formParams = {'x-obs-acl': 'private', 'content-type': 'text/plain'}
+    # Create parameters for a browser-based upload.
+    resp = obsClient.createPostSignature(bucketName, objectKey, expires, formParams)
+
+    print('originPolicy:', resp.originPolicy)
+    print('policy:', resp.policy)
+    print('signature:', resp.signature)
+except:
+    print(traceback.format_exc())
+
+
+

+
Code of an HTML form example is as follows:
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
<html>
+    <head>
+        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+    </head>
+    <body>
+        <form action="http://bucketname.your-endpoint/" method="post" enctype="multipart/form-data">
+            <p>
+                Object key
+            </p>            
+            <!-- Object name  -->
+            <input type="text" name="key" value="objectname" />
+            <p>
+                ACL
+            </p>
+            <!-- Object ACL -->
+            <input type="text" name="x-obs-acl" value="private" />
+            <p>
+                Content-Type
+            </p>
+            <!-- Object MIME type -->
+            <input type="text" name="content-type" value="text/plain" />
+            <p>            
+                <!-- Base64-encoded policy -->
+                <input type="hidden" name="policy" value="*** Provide your policy ***" />
+                <!-- AK -->
+                <input type="hidden" name="AccessKeyId" value="*** Provide your access key ***"/>
+                <!-- Signature string information -->
+                <input type="hidden" name="signature" value="*** Provide your signature ***"/>
+                <input name="file" type="file" />
+                <input name="submit" value="Upload" type="submit" />
+            </p>
+        </form>
+    </body>
+</html>
+
+
+
+
  • Values of policy and signature in the HTML form are obtained from the returned results of ObsClient.createPostSignature.
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0908.html b/docs/obs_3rd_party/python_sdk/obs_22_0908.html new file mode 100644 index 000000000..dfffddc73 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0908.html @@ -0,0 +1,1099 @@ + + +

Downloading an Object - Binary (SDK for Python)

+

Function

This API downloads an object in binary from OBS to your local computer.

+
+

Restrictions

+
+

Method

ObsClient.getObject(bucketName, objectKey, downloadPath, getObjectRequest, headers, loadStreamInMemory, progressCallback, extensionHeaders)
+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

str

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

downloadPath

+

str

+

No

+

Explanation:

+

The download path with the file name contained, for example, aa/bb.txt.

+

Default value:

+

None

+

getObjectRequest

+

GetObjectRequest

+

No

+

Explanation:

+

Additional parameters of an object download request

+

Value range:

+

See Table 2.

+

Default value:

+

None

+

headers

+

GetObjectHeader

+

No

+

Explanation:

+

Headers in the request used for obtaining the storage class, redundancy policy, and other basic information about the object

+

Value range:

+

See Table 3.

+

Default value:

+

None

+

loadStreamInMemory

+

bool

+

No

+

Explanation:

+

Whether to load the data stream of the object to memory

+

Value range:

+

True: The obtained data stream is loaded to memory with downloadPath ignored.

+

False: The obtained data stream is not loaded to memory.

+

Default value:

+

False

+

progressCallback

+

callable

+

No

+

Explanation:

+

Callback function for obtaining the download progress

+

Default value:

+

None

+
NOTE:

This function contains the following parameters in sequence: number of downloaded bytes, total number of bytes, and used time (in seconds). For details about the sample code, see Downloading an Object - Obtaining the Download Progress (SDK for Python).

+
+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 GetObjectRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

cache_control

+

str

+

No

+

Explanation:

+

Cache-Control is rewritten in the response.

+

Default value:

+

None

+

content_disposition

+

str

+

No

+

Explanation:

+

Content-Disposition is rewritten in the response.

+

Default value:

+

None

+

content_encoding

+

str

+

No

+

Explanation:

+

Content-Encoding is rewritten in the response.

+

Default value:

+

None

+

content_language

+

str

+

No

+

Explanation:

+

Content-Language is rewritten in the response.

+

Default value:

+

None

+

content_type

+

str

+

No

+

Explanation:

+

Content-Type is rewritten in the response.

+

Default value:

+

None

+

expires

+

str

+

No

+

Explanation:

+

Expires is rewritten in the response.

+

Default value:

+

None

+

versionId

+

str

+

No

+

Explanation:

+

Object version ID, for example, G001117FCE89978B0000401205D5DC9

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None. If this parameter is left blank, the latest version of the object is obtained.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 GetObjectHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

range

+

str

+

No

+

Explanation:

+

Download range. For example, 0-999 indicates the download range is from byte 1 to byte 1,000.

+

Value range:

+

Value range: 0 to the object length minus 1. Format: x-y, indicating the range is from byte x+1 to byte y+1

+

Restrictions:

+

The upper limit of range is the length of the object minus 1. If the specified value exceeds this limit, the length of the object minus 1 is used.

+

Default value:

+

None

+

if_match

+

str

+

No

+

Explanation:

+

Preset ETag. If the ETag of the object to be downloaded is the same as the preset ETag, the object is returned. Otherwise, an error is returned.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

if_none_match

+

str

+

No

+

Explanation:

+

Preset ETag. If the ETag of the object to be downloaded is different from the preset ETag, the object is returned. Otherwise, an error is returned.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

if_modified_since

+

str

+

or

+

DateTime

+

No

+

Explanation:

+

The object is returned if it has been modified since the specified time; otherwise, an error is returned.

+

Restrictions:

+

The value must be in the GMT format. For example, Wed, 25 Mar 2020 02:39:52 GMT. You can refer to Table 4 to specify time.

+

For example, DateTime(year=2023, month=9, day=12)

+

Default value:

+

None

+

if_unmodified_since

+

str

+

or

+

DateTime

+

No

+

Explanation:

+

The object is returned if it has not been modified since the specified time; otherwise, an error is returned.

+

Restrictions:

+

The value must be in the GMT format. For example, Wed, 25 Mar 2020 02:39:52 GMT. You can refer to Table 4 to specify time.

+

For example, DateTime(year=2023, month=9, day=12)

+

Default value:

+

None

+

origin

+

str

+

No

+

Explanation:

+

Origin of the cross-domain request specified by the preflight request. Generally, it is a domain name.

+

Restrictions:

+

Each origin can contain only one wildcard character (*).

+

Default value:

+

None

+

requestHeaders

+

str

+

No

+

Explanation:

+

HTTP headers in a cross-origin request Only CORS requests matching the allowed headers are valid.

+

Restrictions:

+

Each header can contain only one wildcard character (*). Spaces, ampersands (&), colons (:), and less-than signs (<) are not allowed.

+

Default value:

+

None

+

sseHeader

+

SseCHeader

+

No

+

Explanation:

+

Server-side decryption headers. For details, see Table 5.

+

Restrictions:

+

If the object uploaded to the server is encrypted on the server using the encryption key provided by the client, downloading the object requires including the encryption key in the message.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 4 DateTime

Parameter

+

Type

+

Description

+

year

+

int

+

Explanation:

+

Year in UTC

+

Default value:

+

None

+

month

+

int

+

Explanation:

+

Month in UTC

+

Default value:

+

None

+

day

+

int

+

Explanation:

+

Day in UTC

+

Default value:

+

None

+

hour

+

int

+

Explanation:

+

Hour in UTC

+

Restrictions:

+

The value is in 24-hour format.

+

Default value:

+

0

+

min

+

int

+

Explanation:

+

Minute in UTC

+

Default value:

+

0

+

sec

+

int

+

Explanation:

+

Second in UTC

+

Default value:

+

0

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 5 SseCHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

encryption

+

str

+

Yes

+

Explanation:

+

SSE-C used for encrypting objects

+

Value range:

+

AES256

+

Default value:

+

None

+

key

+

str

+

Yes

+

Explanation:

+

Key used in SSE-C encryption. It corresponds to the encryption method. For example, if encryption is set to AES256, the key is calculated using the AES-256 algorithm.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + +
Table 6 List of returned results

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 7 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + +
Table 8 GetResult.body

GetResult.body Type

+

Description

+

ObjectStream

+

Explanation:

+

Response to the request for downloading an object

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 9 ObjectStream

Parameter

+

Type

+

Description

+

response

+

object

+

Explanation:

+

If loadStreamInMemory is set to False and downloadPath is left blank in the request, this parameter is returned and indicates a readable stream. You can read object content from it.

+

Default value:

+

None

+

buffer

+

object

+

Explanation:

+

If loadStreamInMemory is set to True in the request, this parameter is returned and indicates the data stream in the memory.

+

Default value:

+

None

+

size

+

int

+

Explanation:

+

If loadStreamInMemory is set to True in the request, this parameter is returned and indicates the size of the data stream.

+

Value range:

+

An integer greater than or equal to 0, in bytes

+

Default value:

+

None

+

url

+

str

+

Explanation:

+

If loadStreamInMemory is set to False and downloadPath is not left blank, this parameter is returned and indicates the download path.

+

Default value:

+

None

+

deleteMarker

+

bool

+

Explanation:

+

Whether the deleted object is a delete marker

+

Value range:

+
  • True: The deleted object is a delete marker.
  • False: The deleted object is not a delete marker.
+

Default value:

+

False

+

storageClass

+

str

+

Explanation:

+

Object storage class.

+

Value range:

+
  • If the storage class is Standard, leave this parameter blank.
  • For details about the available storage classes, see Table 10.
+

Default value:

+

None

+

accessContorlAllowOrigin

+

str

+

Explanation:

+

If Origin in the request meets the CORS rules of the bucket, AllowedOrigin in the CORS rules is returned. AllowedOrigin indicates the origin from which the requests can access the bucket.

+

Restrictions:

+

Domain name of the origin. Each origin can contain only one wildcard character (*), for example, https://*.vbs.example.com.

+

Default value:

+

None

+

accessContorlAllowHeaders

+

str

+

Explanation:

+

If RequestHeader in the request meets the CORS rules of the bucket, AllowedHeader in the CORS rules is returned. AllowedHeader indicates the allowed headers for cross-origin requests. Only CORS requests matching the allowed headers are valid.

+

Restrictions:

+

Each header can contain only one wildcard character (*). Spaces, ampersands (&), colons (:), and less-than signs (<) are not allowed.

+

Default value:

+

None

+

accessContorlAllowMethods

+

str

+

Explanation:

+

AllowedMethod in the CORS rules of the bucket. It specifies the HTTP method of cross-origin requests, that is, the operation type of buckets and objects.

+

Value range:

+

The following HTTP methods are supported:

+
  • GET
  • PUT
  • HEAD
  • POST
  • DELETE
+

Default value:

+

None

+

accessContorlExposeHeaders

+

str

+

Explanation:

+

ExposeHeader in the CORS rules of the bucket. It specifies the CORS-allowed additional headers in the response. These headers provide additional information to clients. By default, your browser can only access headers Content-Length and Content-Type. If your browser needs to access other headers, add them to a list of the allowed additional headers.

+

Restrictions:

+

Spaces, wildcard characters (*), ampersands (&), colons (:), and less-than signs (<) are not allowed.

+

Default value:

+

None

+

accessContorlMaxAge

+

int

+

Explanation:

+

MaxAgeSeconds in the CORS rules of the bucket. It specifies the time your client can cache the response for a cross-origin request.

+

Restrictions:

+

Each CORS rule can contain only one MaxAgeSeconds.

+

Value range:

+

An integer greater than or equal to 0, in seconds

+

Default value:

+

100

+

contentLength

+

int

+

Explanation:

+

Object size

+

Value range:

+

The value ranges from 0 TB to 48.8 TB, in bytes.

+

Default value:

+

None

+

cacheControl

+

str

+

Explanation:

+

Cache-Control header in the response

+

Default value:

+

None

+

contentDisposition

+

str

+

Explanation:

+

Content-Disposition header in the response

+

Default value:

+

None

+

contentEncoding

+

str

+

Explanation:

+

Content-Encoding header in the response

+

Default value:

+

None

+

contentLanguage

+

str

+

Explanation:

+

Content-Language header in the response

+

Default value:

+

None

+

contentType

+

str

+

Explanation:

+

MIME type of the file to be uploaded. MIME type is a standard way of describing a data type and is used by the browser to decide how to display data.

+

Value range:

+

See What Is Content-Type (MIME)? (Python SDK)

+

Default value:

+

None

+

expires

+

str

+

Explanation:

+

Expires header in the response

+

Default value:

+

None

+

lastModified

+

str

+

Explanation:

+

Time when the last modification was made to the object

+

Restrictions:

+

The time must be in the GMT format, for example, Wed, 25 Mar 2020 02:39:52 GMT.

+

Default value:

+

None

+

etag

+

str

+

Explanation:

+

Base64-encoded, 128-bit MD5 value of an object. ETag is the unique identifier of the object contents and is used to determine whether the contents of an object are changed. For example, if the ETag value is A when an object is uploaded and is B when the object is downloaded, this indicates the contents of the object are changed. The ETag reflects changes only to the contents of an object, not its metadata. Objects created by the upload and copy operations have unique ETags after being encrypted using MD5.

+

Restrictions:

+

If an object is encrypted using server-side encryption, the ETag is not the MD5 value of the object.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

versionId

+

str

+

Explanation:

+

Object version ID.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

restore

+

str

+

Explanation:

+

Restore status of an object. This header is returned when a Cold object is being restored or has been restored.

+

For example, ongoing-request="true" indicates that the object is being restored. ongoing-request="false", expiry-date="Wed, 7 Nov 2012 00:00:00 GMT" indicates that the object has been restored. expiry-date indicates when the restored object expires.

+

Restrictions:

+

This parameter is only available for Cold objects.

+

Default value:

+

None

+

expiration

+

str

+

Explanation:

+

Expiration details Example: "expiry-date=\"Mon, 11 Sep 2023 00:00:00 GMT\""

+

Default value:

+

None

+

sseKms

+

str

+

Explanation:

+

Objects are encrypted using SSE-KMS on the server side.

+

Value range:

+

kms

+

Default value:

+

None

+

sseKmsKey

+

str

+

Explanation:

+

ID of the KMS master key when SSE-KMS is used

+

Value range:

+

Valid value formats are as follows:

+
  1. regionID:domainID:key/key_id
  2. key_id
+

In the preceding formats:

+ +

Default value:

+
  • If this parameter is not specified, the default master key will be used.
  • If there is no such a default master key, the system will create one and use it by default.
+

sseC

+

str

+

Explanation:

+

SSE-C algorithm

+

Value range:

+

AES256

+

Default value:

+

None

+

sseCKeyMd5

+

str

+

Explanation:

+

MD5 value of the key for encrypting objects when SSE-C is used. This value is used to check whether any error occurs during the transmission of the key.

+

Restrictions:

+

The value is encrypted by MD5 and then encoded by Base64, for example, 4XvB3tbNTN+tIEVa0/fGaQ==.

+

Default value:

+

None

+

websiteRedirectLocation

+

str

+

Explanation:

+

If the bucket is configured with website hosting, the request for obtaining the object can be redirected to another object in the bucket or an external URL. This parameter specifies the address the request for the object is redirected to.

+

The request is redirected to object anotherPage.html in the same bucket:

+

WebsiteRedirectLocation:/anotherPage.html

+

The request is redirected to an external URL http://www.example.com/:

+

WebsiteRedirectLocation:http://www.example.com/

+

OBS obtains the specified value from the header and stores it in the object metadata WebsiteRedirectLocation.

+

Restrictions:

+
  • The value must start with a slash (/), http://, or https:// and cannot exceed 2 KB.
  • OBS only supports redirection for objects in the root directory of a bucket.
+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 10 StorageClass

Parameter

+

Type

+

Description

+

STANDARD

+

Standard storage class

+

Explanation:

+

Features low access latency and high throughput and is used for storing massive, frequently accessed (multiple times a month) or small objects (< 1 MB) requiring quick response.

+

WARM

+

Warm storage class

+

Explanation:

+

Used for storing data that is semi-frequently accessed (fewer than 12 times a year) but is instantly available when needed.

+

COLD

+

Cold storage class

+

Explanation:

+

Used for storing rarely accessed (once a year) data.

+
+
+
+

Code Examples

This example downloads an object in binary mode.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName="examplebucket"
+    objectKey="objectname"
+    # If loadStreamInMemory is set to True, downloadpath will be invalid, and data streams will be downloaded to the memory.
+    # Download the object using streaming.
+    resp = obsClient.getObject(bucketName=bucketName,objectKey=objectKey, loadStreamInMemory=True)
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Get Object Succeeded')
+        print('requestId:', resp.requestId)
+        # Obtain the object content.
+        print('buffer:', resp.body.buffer)
+        print('size:', resp.body.size)
+    else:
+        print('Get Object Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Get Object Failed')
+    print(traceback.format_exc())
+
+
+

In a binary download, if loadStreamInMemory is set to True, the object content is contained in the body.buffer parameter in the returned result.

+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0909.html b/docs/obs_3rd_party/python_sdk/obs_22_0909.html new file mode 100644 index 000000000..d1cffc99a --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0909.html @@ -0,0 +1,1113 @@ + + +

Downloading an Object - Streaming (SDK for Python)

+

Function

This API downloads an object using streaming from OBS to your local computer.

+
+

Restrictions

+
+

Method

ObsClient.getObject(bucketName, objectKey, downloadPath, getObjectRequest, headers, loadStreamInMemory, progressCallback, extensionHeaders)
+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

str

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

downloadPath

+

str

+

No

+

Explanation:

+

The download path with the file name contained, for example, aa/bb.txt.

+

Default value:

+

None

+

getObjectRequest

+

GetObjectRequest

+

No

+

Explanation:

+

Additional parameters of an object download request

+

Value range:

+

See Table 2.

+

Default value:

+

None

+

headers

+

GetObjectHeader

+

No

+

Explanation:

+

Headers in the request used for obtaining the storage class, redundancy policy, and other basic information about the object

+

Value range:

+

See Table 3.

+

Default value:

+

None

+

loadStreamInMemory

+

bool

+

No

+

Explanation:

+

Whether to load the data stream of the object to memory

+

Value range:

+

True: The obtained data stream is loaded to memory with downloadPath ignored.

+

False: The obtained data stream is not loaded to memory.

+

Default value:

+

False

+

progressCallback

+

callable

+

No

+

Explanation:

+

Callback function for obtaining the download progress

+

Default value:

+

None

+
NOTE:

This function contains the following parameters in sequence: number of downloaded bytes, total number of bytes, and used time (in seconds). For details about the sample code, see Downloading an Object - Obtaining the Download Progress (SDK for Python).

+
+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 GetObjectRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

cache_control

+

str

+

No

+

Explanation:

+

Cache-Control is rewritten in the response.

+

Default value:

+

None

+

content_disposition

+

str

+

No

+

Explanation:

+

Content-Disposition is rewritten in the response.

+

Default value:

+

None

+

content_encoding

+

str

+

No

+

Explanation:

+

Content-Encoding is rewritten in the response.

+

Default value:

+

None

+

content_language

+

str

+

No

+

Explanation:

+

Content-Language is rewritten in the response.

+

Default value:

+

None

+

content_type

+

str

+

No

+

Explanation:

+

Content-Type is rewritten in the response.

+

Default value:

+

None

+

expires

+

str

+

No

+

Explanation:

+

Expires is rewritten in the response.

+

Default value:

+

None

+

versionId

+

str

+

No

+

Explanation:

+

Object version ID, for example, G001117FCE89978B0000401205D5DC9

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None. If this parameter is left blank, the latest version of the object is obtained.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 GetObjectHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

range

+

str

+

No

+

Explanation:

+

Download range. For example, 0-999 indicates the download range is from byte 1 to byte 1,000.

+

Value range:

+

Value range: 0 to the object length minus 1. Format: x-y, indicating the range is from byte x+1 to byte y+1

+

Restrictions:

+

The upper limit of range is the length of the object minus 1. If the specified value exceeds this limit, the length of the object minus 1 is used.

+

Default value:

+

None

+

if_match

+

str

+

No

+

Explanation:

+

Preset ETag. If the ETag of the object to be downloaded is the same as the preset ETag, the object is returned. Otherwise, an error is returned.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

if_none_match

+

str

+

No

+

Explanation:

+

Preset ETag. If the ETag of the object to be downloaded is different from the preset ETag, the object is returned. Otherwise, an error is returned.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

if_modified_since

+

str

+

or

+

DateTime

+

No

+

Explanation:

+

The object is returned if it has been modified since the specified time; otherwise, an error is returned.

+

Restrictions:

+

The value must be in the GMT format. For example, Wed, 25 Mar 2020 02:39:52 GMT. You can refer to Table 4 to specify time.

+

For example, DateTime(year=2023, month=9, day=12)

+

Default value:

+

None

+

if_unmodified_since

+

str

+

or

+

DateTime

+

No

+

Explanation:

+

The object is returned if it has not been modified since the specified time; otherwise, an error is returned.

+

Restrictions:

+

The value must be in the GMT format. For example, Wed, 25 Mar 2020 02:39:52 GMT. You can refer to Table 4 to specify time.

+

For example, DateTime(year=2023, month=9, day=12)

+

Default value:

+

None

+

origin

+

str

+

No

+

Explanation:

+

Origin of the cross-domain request specified by the preflight request. Generally, it is a domain name.

+

Restrictions:

+

Each origin can contain only one wildcard character (*).

+

Default value:

+

None

+

requestHeaders

+

str

+

No

+

Explanation:

+

HTTP headers in a cross-origin request Only CORS requests matching the allowed headers are valid.

+

Restrictions:

+

Each header can contain only one wildcard character (*). Spaces, ampersands (&), colons (:), and less-than signs (<) are not allowed.

+

Default value:

+

None

+

sseHeader

+

SseCHeader

+

No

+

Explanation:

+

Server-side decryption headers. For details, see Table 5.

+

Restrictions:

+

If the object uploaded to the server is encrypted on the server using the encryption key provided by the client, downloading the object requires including the encryption key in the message.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 4 DateTime

Parameter

+

Type

+

Description

+

year

+

int

+

Explanation:

+

Year in UTC

+

Default value:

+

None

+

month

+

int

+

Explanation:

+

Month in UTC

+

Default value:

+

None

+

day

+

int

+

Explanation:

+

Day in UTC

+

Default value:

+

None

+

hour

+

int

+

Explanation:

+

Hour in UTC

+

Restrictions:

+

The value is in 24-hour format.

+

Default value:

+

0

+

min

+

int

+

Explanation:

+

Minute in UTC

+

Default value:

+

0

+

sec

+

int

+

Explanation:

+

Second in UTC

+

Default value:

+

0

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 5 SseCHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

encryption

+

str

+

Yes

+

Explanation:

+

SSE-C used for encrypting objects

+

Value range:

+

AES256

+

Default value:

+

None

+

key

+

str

+

Yes

+

Explanation:

+

Key used in SSE-C encryption. It corresponds to the encryption method. For example, if encryption is set to AES256, the key is calculated using the AES-256 algorithm.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+
+
+
+

List of returned results

+
+ + + + + + + +
Table 6 List of returned results

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 7 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + +
Table 8 GetResult.body

GetResult.body Type

+

Description

+

ObjectStream

+

Explanation:

+

Response to the request for downloading an object

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 9 ObjectStream

Parameter

+

Type

+

Description

+

response

+

object

+

Explanation:

+

If loadStreamInMemory is set to False and downloadPath is left blank in the request, this parameter is returned and indicates a readable stream. You can read object content from it.

+

Default value:

+

None

+

buffer

+

object

+

Explanation:

+

If loadStreamInMemory is set to True in the request, this parameter is returned and indicates the data stream in the memory.

+

Default value:

+

None

+

size

+

int

+

Explanation:

+

If loadStreamInMemory is set to True in the request, this parameter is returned and indicates the size of the data stream.

+

Value range:

+

An integer greater than or equal to 0, in bytes

+

Default value:

+

None

+

url

+

str

+

Explanation:

+

If loadStreamInMemory is set to False and downloadPath is not left blank, this parameter is returned and indicates the download path.

+

Default value:

+

None

+

deleteMarker

+

bool

+

Explanation:

+

Whether the deleted object is a delete marker

+

Value range:

+
  • True: The deleted object is a delete marker.
  • False: The deleted object is not a delete marker.
+

Default value:

+

False

+

storageClass

+

str

+

Explanation:

+

Object storage class.

+

Value range:

+
  • If the storage class is Standard, leave this parameter blank.
  • For details about the available storage classes, see Table 10.
+

Default value:

+

None

+

accessContorlAllowOrigin

+

str

+

Explanation:

+

If Origin in the request meets the CORS rules of the bucket, AllowedOrigin specified in the CORS rules is returned. AllowedOrigin indicates the origin from which the requests can access the bucket.

+

Restrictions:

+

Domain name of the origin. Each origin can contain only one wildcard character (*), for example, https://*.vbs.example.com.

+

Default value:

+

None

+

accessContorlAllowHeaders

+

str

+

Explanation:

+

If RequestHeader in the request meets the CORS rules of the bucket, AllowedHeader specified in the CORS rules is returned. AllowedHeader indicates the allowed headers for cross-origin requests. Only CORS requests matching the allowed headers are valid.

+

Restrictions:

+

Each header can contain only one wildcard character (*). Spaces, ampersands (&), colons (:), and less-than signs (<) are not allowed.

+

Default value:

+

None

+

accessContorlAllowMethods

+

str

+

Explanation:

+

AllowedMethod in the CORS rules of the bucket. It specifies the HTTP method of cross-origin requests, that is, the operation type of buckets and objects.

+

Value range:

+

The following HTTP methods are supported:

+
  • GET
  • PUT
  • HEAD
  • POST
  • DELETE
+

Default value:

+

None

+

accessContorlExposeHeaders

+

str

+

Explanation:

+

ExposeHeader in the CORS rules of the bucket. It specifies the CORS-allowed additional headers in the response. These headers provide additional information to clients. By default, your browser can only access headers Content-Length and Content-Type. If your browser needs to access other headers, add them to a list of the allowed additional headers.

+

Restrictions:

+

Spaces, wildcard characters (*), ampersands (&), colons (:), and less-than signs (<) are not allowed.

+

Default value:

+

None

+

accessContorlMaxAge

+

int

+

Explanation:

+

MaxAgeSeconds in the CORS rules of the bucket. It specifies the time your client can cache the response for a cross-origin request.

+

Restrictions:

+

Each CORS rule can contain only one MaxAgeSeconds.

+

Value range:

+

An integer greater than or equal to 0, in seconds

+

Default value:

+

100

+

contentLength

+

int

+

Explanation:

+

Object size

+

Value range:

+

The value ranges from 0 TB to 48.8 TB, in bytes.

+

Default value:

+

None

+

cacheControl

+

str

+

Explanation:

+

Cache-Control header in the response

+

Default value:

+

None

+

contentDisposition

+

str

+

Explanation:

+

Content-Disposition header in the response

+

Default value:

+

None

+

contentEncoding

+

str

+

Explanation:

+

Content-Encoding header in the response

+

Default value:

+

None

+

contentLanguage

+

str

+

Explanation:

+

Content-Language header in the response

+

Default value:

+

None

+

contentType

+

str

+

Explanation:

+

MIME type of the file to be uploaded. MIME type is a standard way of describing a data type and is used by the browser to decide how to display data.

+

Value range:

+

See What Is Content-Type (MIME)? (Python SDK)

+

Default value:

+

None

+

expires

+

str

+

Explanation:

+

Expires header in the response

+

Default value:

+

None

+

lastModified

+

str

+

Explanation:

+

Time when the last modification was made to the object

+

Restrictions:

+

The time must be in the GMT format, for example, Wed, 25 Mar 2020 02:39:52 GMT.

+

Default value:

+

None

+

etag

+

str

+

Explanation:

+

Base64-encoded, 128-bit MD5 value of an object. ETag is the unique identifier of the object contents and is used to determine whether the contents of an object are changed. For example, if the ETag value is A when an object is uploaded and is B when the object is downloaded, this indicates the contents of the object are changed. The ETag reflects changes only to the contents of an object, not its metadata. Objects created by the upload and copy operations have unique ETags after being encrypted using MD5.

+

Restrictions:

+

If an object is encrypted using server-side encryption, the ETag is not the MD5 value of the object.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

versionId

+

str

+

Explanation:

+

Object version ID.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

restore

+

str

+

Explanation:

+

Restore status of an object. This header is returned when a Cold object is being restored or has been restored.

+

For example, ongoing-request="true" indicates that the object is being restored. ongoing-request="false", expiry-date="Wed, 7 Nov 2012 00:00:00 GMT" indicates that the object has been restored. expiry-date indicates when the restored object expires.

+

Restrictions:

+

If the object is not in the Cold storage class, this parameter is left blank.

+

Default value:

+

None

+

expiration

+

str

+

Explanation:

+

Expiration details. Example: "expiry-date=\"Mon, 11 Sep 2023 00:00:00 GMT\""

+

Default value:

+

None

+

sseKms

+

str

+

Explanation:

+

Objects are encrypted using SSE-KMS on the server side.

+

Value range:

+

kms

+

Default value:

+

None

+

sseKmsKey

+

str

+

Explanation:

+

ID of the KMS master key when SSE-KMS is used

+

Value range:

+

Valid value formats are as follows:

+
  1. regionID:domainID:key/key_id
  2. key_id
+

In the preceding formats:

+ +

Default value:

+
  • If this parameter is not specified, the default master key will be used.
  • If there is no such a default master key, the system will create one and use it by default.
+

sseC

+

str

+

Explanation:

+

SSE-C algorithm

+

Value range:

+

AES256

+

Default value:

+

None

+

sseCKeyMd5

+

str

+

Explanation:

+

MD5 value of the key for encrypting objects when SSE-C is used. This value is used to check whether any error occurs during the transmission of the key.

+

Restrictions:

+

The value is encrypted by MD5 and then encoded by Base64, for example, 4XvB3tbNTN+tIEVa0/fGaQ==.

+

Default value:

+

None

+

websiteRedirectLocation

+

str

+

Explanation:

+

If the bucket is configured with website hosting, the request for obtaining the object can be redirected to another object in the bucket or an external URL. This parameter specifies the address the request for the object is redirected to.

+

The request is redirected to object anotherPage.html in the same bucket:

+

WebsiteRedirectLocation:/anotherPage.html

+

The request is redirected to an external URL http://www.example.com/:

+

WebsiteRedirectLocation:http://www.example.com/

+

OBS obtains the specified value from the header and stores it in the object metadata WebsiteRedirectLocation.

+

Restrictions:

+
  • The value must start with a slash (/), http://, or https:// and cannot exceed 2 KB.
  • OBS only supports redirection for objects in the root directory of a bucket.
+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 10 StorageClass

Parameter

+

Type

+

Description

+

STANDARD

+

Standard storage class

+

Explanation:

+

Features low access latency and high throughput and is used for storing massive, frequently accessed (multiple times a month) or small objects (< 1 MB) requiring quick response.

+

WARM

+

Warm storage class

+

Explanation:

+

Used for storing data that is semi-frequently accessed (fewer than 12 times a year) but is instantly available when needed.

+

COLD

+

Cold storage class

+

Explanation:

+

Used for storing rarely accessed (once a year) data.

+
+
+
+

Code Examples

This example downloads an object using streaming.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
from obs import GetObjectRequest
+from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    # Specify the additional parameter of an object download request.
+    getObjectRequest = GetObjectRequest()
+    # Rewrite the Content-Type header in the response.
+    getObjectRequest.content_type = 'text/plain'
+    bucketName="examplebucket"
+    objectKey="objectname"
+    # Download the object using streaming.
+    resp = obsClient.getObject(bucketName=bucketName,objectKey=objectKey, getObjectRequest=getObjectRequest, loadStreamInMemory=False)
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Get Object Succeeded')
+        print('requestId:', resp.requestId)
+        # Read the object content.
+        while True:
+            chunk = resp.body.response.read(65536)
+            if not chunk:
+                break
+            print(chunk)
+        resp.body.response.close()
+    else:
+        print('Get Object Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Get Object Failed')  
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0910.html b/docs/obs_3rd_party/python_sdk/obs_22_0910.html new file mode 100644 index 000000000..c148f6d17 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0910.html @@ -0,0 +1,1105 @@ + + +

Downloading an Object - File-Based (SDK for Python)

+

Function

This API downloads an object as a file from OBS to your local computer.

+
+

Restrictions

+
+

Method

ObsClient.getObject(bucketName, objectKey, downloadPath, getObjectRequest, headers, loadStreamInMemory, progressCallback, extensionHeaders)
+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

str

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

downloadPath

+

str

+

No

+

Explanation:

+

The download path with the file name contained, for example, aa/bb.txt.

+

Default value:

+

None

+

getObjectRequest

+

GetObjectRequest

+

No

+

Explanation:

+

Additional parameters of an object download request

+

Value range:

+

See Table 2.

+

headers

+

GetObjectHeader

+

No

+

Explanation:

+

Headers in the request used for obtaining the storage class, redundancy policy, and other basic information about the object

+

Value range:

+

See Table 3.

+

loadStreamInMemory

+

bool

+

No

+

Explanation:

+

Whether to load the data stream of the object to memory

+

Value range:

+

True: The obtained data stream is loaded to memory with downloadPath ignored.

+

False: The obtained data stream is not loaded to memory.

+

Default value:

+

False

+

progressCallback

+

callable

+

No

+

Explanation:

+

Callback function for obtaining the download progress

+

Default value:

+

None

+
NOTE:

This function contains the following parameters in sequence: number of downloaded bytes, total number of bytes, and used time (in seconds). For details about the sample code, see Downloading an Object - Obtaining the Download Progress (SDK for Python).

+
+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 GetObjectRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

cache_control

+

str

+

No

+

Explanation:

+

Cache-Control is rewritten in the response.

+

Default value:

+

None

+

content_disposition

+

str

+

No

+

Explanation:

+

Content-Disposition is rewritten in the response.

+

Default value:

+

None

+

content_encoding

+

str

+

No

+

Explanation:

+

Content-Encoding is rewritten in the response.

+

Default value:

+

None

+

content_language

+

str

+

No

+

Explanation:

+

Content-Language is rewritten in the response.

+

Default value:

+

None

+

content_type

+

str

+

No

+

Explanation:

+

Content-Type is rewritten in the response.

+

Default value:

+

None

+

expires

+

str

+

No

+

Explanation:

+

Expires is rewritten in the response.

+

Default value:

+

None

+

versionId

+

str

+

No

+

Explanation:

+

Object version ID, for example, G001117FCE89978B0000401205D5DC9

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None. If this parameter is left blank, the latest version of the object is obtained.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 GetObjectHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

range

+

str

+

No

+

Explanation:

+

Download range. For example, 0-999 indicates the download range is from byte 1 to byte 1,000.

+

Value range:

+

Value range: 0 to the object length minus 1. Format: x-y, indicating the range is from byte x+1 to byte y+1

+

Restrictions:

+

The upper limit of range is the length of the object minus 1. If the specified value exceeds this limit, the length of the object minus 1 is used.

+

Default value:

+

None

+

if_match

+

str

+

No

+

Explanation:

+

Preset ETag. If the ETag of the object to be downloaded is the same as the preset ETag, the object is returned. Otherwise, an error is returned.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

if_none_match

+

str

+

No

+

Explanation:

+

Preset ETag. If the ETag of the object to be downloaded is different from the preset ETag, the object is returned. Otherwise, an error is returned.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

if_modified_since

+

str

+

or

+

DateTime

+

No

+

Explanation:

+

The object is returned if it has been modified since the specified time; otherwise, an error is returned.

+

Restrictions:

+

The value must be in the GMT format. For example, Wed, 25 Mar 2020 02:39:52 GMT. You can refer to Table 4 to specify time.

+

For example, DateTime(year=2023, month=9, day=12)

+

Default value:

+

None

+

if_unmodified_since

+

str

+

or

+

DateTime

+

No

+

Explanation:

+

The object is returned if it has not been modified since the specified time; otherwise, an error is returned.

+

Restrictions:

+

The value must be in the GMT format. For example, Wed, 25 Mar 2020 02:39:52 GMT. You can refer to Table 4 to specify time.

+

For example, DateTime(year=2023, month=9, day=12)

+

Default value:

+

None

+

origin

+

str

+

No

+

Explanation:

+

Origin of the cross-domain request specified by the preflight request. Generally, it is a domain name.

+

Restrictions:

+

Each origin can contain only one wildcard character (*).

+

Default value:

+

None

+

requestHeaders

+

str

+

No

+

Explanation:

+

HTTP headers in a cross-origin request Only CORS requests matching the allowed headers are valid.

+

Restrictions:

+

Each header can contain only one wildcard character (*). Spaces, ampersands (&), colons (:), and less-than signs (<) are not allowed.

+

Default value:

+

None

+

sseHeader

+

SseCHeader

+

No

+

Explanation:

+

Server-side decryption headers. For details, see Table 5.

+

Restrictions:

+

If the object uploaded to the server is encrypted on the server using the encryption key provided by the client, downloading the object requires including the encryption key in the message.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 4 DateTime

Parameter

+

Type

+

Description

+

year

+

int

+

Explanation:

+

Year in UTC

+

Default value:

+

None

+

month

+

int

+

Explanation:

+

Month in UTC

+

Default value:

+

None

+

day

+

int

+

Explanation:

+

Day in UTC

+

Default value:

+

None

+

hour

+

int

+

Explanation:

+

Hour in UTC

+

Restrictions:

+

The value is in 24-hour format.

+

Default value:

+

0

+

min

+

int

+

Explanation:

+

Minute in UTC

+

Default value:

+

0

+

sec

+

int

+

Explanation:

+

Second in UTC

+

Default value:

+

0

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 5 SseCHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

encryption

+

str

+

Yes

+

Explanation:

+

SSE-C used for encrypting objects

+

Value range:

+

AES256

+

Default value:

+

None

+

key

+

str

+

Yes

+

Explanation:

+

Key used in SSE-C encryption. It corresponds to the encryption method. For example, if encryption is set to AES256, the key is calculated using the AES-256 algorithm.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+
+
+
+

List of returned results

+
+ + + + + + + +
Table 6 List of returned results

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 7 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + +
Table 8 GetResult.body

GetResult.body Type

+

Description

+

ObjectStream

+

Explanation:

+

Response to the request for downloading an object

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 9 ObjectStream

Parameter

+

Type

+

Description

+

response

+

object

+

Explanation:

+

If loadStreamInMemory is set to False and downloadPath is left blank in the request, this parameter is returned and indicates a readable stream. You can read object content from it.

+

Default value:

+

None

+

buffer

+

object

+

Explanation:

+

If loadStreamInMemory is set to True in the request, this parameter is returned and indicates the data stream in the memory.

+

Default value:

+

None

+

size

+

int

+

Explanation:

+

If loadStreamInMemory is set to True in the request, this parameter is returned and indicates the size of the data stream.

+

Value range:

+

An integer greater than or equal to 0, in bytes

+

Default value:

+

None

+

url

+

str

+

Explanation:

+

If loadStreamInMemory is set to False and downloadPath is not left blank, this parameter is returned and indicates the download path.

+

Default value:

+

None

+

deleteMarker

+

bool

+

Explanation:

+

Whether the deleted object is a delete marker

+

Value range:

+
  • True: The deleted object is a delete marker.
  • False: The deleted object is not a delete marker.
+

Default value:

+

False

+

storageClass

+

str

+

Explanation:

+

Object storage class.

+

Value range:

+
  • If the storage class is Standard, leave this parameter blank.
  • For details about the available storage classes, see Table 10.
+

Default value:

+

None

+

accessContorlAllowOrigin

+

str

+

Explanation:

+

If Origin in the request meets the CORS rules of the bucket, AllowedOrigin specified in the CORS rules is returned. AllowedOrigin indicates the origin from which the requests can access the bucket.

+

Restrictions:

+

Domain name of the origin. Each origin can contain only one wildcard character (*), for example, https://*.vbs.example.com.

+

Default value:

+

None

+

accessContorlAllowHeaders

+

str

+

Explanation:

+

If RequestHeader in the request meets the CORS rules of the bucket, AllowedHeader specified in the CORS rules is returned. AllowedHeader indicates the allowed headers for cross-origin requests. Only CORS requests matching the allowed headers are valid.

+

Restrictions:

+

Each header can contain only one wildcard character (*). Spaces, ampersands (&), colons (:), and less-than signs (<) are not allowed.

+

Default value:

+

None

+

accessContorlAllowMethods

+

str

+

Explanation:

+

AllowedMethod in the CORS rules of the bucket. It specifies the HTTP method of cross-origin requests, that is, the operation type of buckets and objects.

+

Value range:

+

The following HTTP methods are supported:

+
  • GET
  • PUT
  • HEAD
  • POST
  • DELETE
+

Default value:

+

None

+

accessContorlExposeHeaders

+

str

+

Explanation:

+

ExposeHeader in the CORS rules of the bucket. It specifies the CORS-allowed additional headers in the response. These headers provide additional information to clients. By default, your browser can only access headers Content-Length and Content-Type. If your browser needs to access other headers, add them to a list of the allowed additional headers.

+

Restrictions:

+

Spaces, wildcard characters (*), ampersands (&), colons (:), and less-than signs (<) are not allowed.

+

Default value:

+

None

+

accessContorlMaxAge

+

int

+

Explanation:

+

MaxAgeSeconds in the CORS rules of the bucket. It specifies the time your client can cache the response for a cross-origin request.

+

Restrictions:

+

Each CORS rule can contain only one MaxAgeSeconds.

+

Value range:

+

An integer greater than or equal to 0, in seconds

+

Default value:

+

100

+

contentLength

+

int

+

Explanation:

+

Object size

+

Value range:

+

The value ranges from 0 TB to 48.8 TB, in bytes.

+

Default value:

+

None

+

cacheControl

+

str

+

Explanation:

+

Cache-Control header in the response

+

Default value:

+

None

+

contentDisposition

+

str

+

Explanation:

+

Content-Disposition header in the response

+

Default value:

+

None

+

contentEncoding

+

str

+

Explanation:

+

Content-Encoding header in the response

+

Default value:

+

None

+

contentLanguage

+

str

+

Explanation:

+

Content-Language header in the response

+

Default value:

+

None

+

contentType

+

str

+

Explanation:

+

MIME type of the file to be uploaded. MIME type is a standard way of describing a data type and is used by the browser to decide how to display data.

+

Value range:

+

See What Is Content-Type (MIME)? (Python SDK)

+

Default value:

+

None

+

expires

+

str

+

Explanation:

+

Expires header in the response

+

Default value:

+

None

+

lastModified

+

str

+

Explanation:

+

Time when the last modification was made to the object

+

Restrictions:

+

The time must be in the GMT format, for example, Wed, 25 Mar 2020 02:39:52 GMT.

+

Default value:

+

None

+

etag

+

str

+

Explanation:

+

Base64-encoded, 128-bit MD5 value of an object. ETag is the unique identifier of the object contents and is used to determine whether the contents of an object are changed. For example, if the ETag value is A when an object is uploaded and is B when the object is downloaded, this indicates the contents of the object are changed. The ETag reflects changes only to the contents of an object, not its metadata. Objects created by the upload and copy operations have unique ETags after being encrypted using MD5.

+

Restrictions:

+

If an object is encrypted using server-side encryption, the ETag is not the MD5 value of the object.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

versionId

+

str

+

Explanation:

+

Object version ID.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

restore

+

str

+

Explanation:

+

Restore status of an object. This header is returned when a Cold object is being restored or has been restored.

+

For example, ongoing-request="true" indicates that the object is being restored. ongoing-request="false", expiry-date="Wed, 7 Nov 2012 00:00:00 GMT" indicates that the object has been restored. expiry-date indicates when the restored object expires.

+

Restrictions:

+

If the object is not in the Cold storage class, this parameter is left blank.

+

Default value:

+

None

+

expiration

+

str

+

Explanation:

+

Expiration details. Example: "expiry-date=\"Mon, 11 Sep 2023 00:00:00 GMT\""

+

Default value:

+

None

+

sseKms

+

str

+

Explanation:

+

Objects are encrypted using SSE-KMS on the server side.

+

Value range:

+

kms

+

Default value:

+

None

+

sseKmsKey

+

str

+

Explanation:

+

ID of the KMS master key when SSE-KMS is used

+

Value range:

+

Valid value formats are as follows:

+
  1. regionID:domainID:key/key_id
  2. key_id
+

In the preceding formats:

+ +

Default value:

+
  • If this parameter is not specified, the default master key will be used.
  • If there is no such a default master key, the system will create one and use it by default.
+

sseC

+

str

+

Explanation:

+

SSE-C algorithm

+

Value range:

+

AES256

+

Default value:

+

None

+

sseCKeyMd5

+

str

+

Explanation:

+

MD5 value of the key for encrypting objects when SSE-C is used. This value is used to check whether any error occurs during the transmission of the key.

+

Restrictions:

+

The value is encrypted by MD5 and then encoded by Base64, for example, 4XvB3tbNTN+tIEVa0/fGaQ==.

+

Default value:

+

None

+

websiteRedirectLocation

+

str

+

Explanation:

+

If the bucket is configured with website hosting, the request for obtaining the object can be redirected to another object in the bucket or an external URL. This parameter specifies the address the request for the object is redirected to.

+

The request is redirected to object anotherPage.html in the same bucket:

+

WebsiteRedirectLocation:/anotherPage.html

+

The request is redirected to an external URL http://www.example.com/:

+

WebsiteRedirectLocation:http://www.example.com/

+

OBS obtains the specified value from the header and stores it in the object metadata WebsiteRedirectLocation.

+

Restrictions:

+
  • The value must start with a slash (/), http://, or https:// and cannot exceed 2 KB.
  • OBS only supports redirection for objects in the root directory of a bucket.
+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 10 StorageClass

Parameter

+

Type

+

Description

+

STANDARD

+

Standard storage class

+

Explanation:

+

Features low access latency and high throughput and is used for storing massive, frequently accessed (multiple times a month) or small objects (< 1 MB) requiring quick response.

+

WARM

+

Warm storage class

+

Explanation:

+

Used for storing data that is semi-frequently accessed (fewer than 12 times a year) but is instantly available when needed.

+

COLD

+

Cold storage class

+

Explanation:

+

Used for storing rarely accessed (once a year) data.

+
+
+
+

Code Examples

This example downloads a file.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
from obs import GetObjectHeader
+from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    # Specify the additional headers of the request for downloading an object.
+    headers = GetObjectHeader()
+    # (Optional) The object is returned if it has been modified since the specified time; otherwise, an error is returned.
+    headers.if_modified_since = 'date'
+    # Specify the full path (localfile as an example) to which objects are downloaded. The full path contains the local file name.
+    downloadPath = 'localfile'
+    bucketName = "examplebucket"
+    objectKey = "objectname"
+    # Perform the file-based download.
+    resp = obsClient.getObject(bucketName, objectKey, downloadPath, headers=headers)
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Get Object Succeeded')
+        print('requestId:', resp.requestId)
+        print('url:', resp.body.url)
+    else:
+        print('Get Object Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Get Object Failed') 
+    print(traceback.format_exc())
+
+
+
  • Use downloadPath to specify the path for saving the file to be downloaded. (If you choose the current directory, it must be contained in the path, for example, ./xxx. The path cannot contain only the file name xxx.)
  • If loadStreamInMemory is set to True, downloadPath is omitted.
+
+

If the value of downloadPath is a file path instead of a folder path, the object is downloaded as the file.

+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0911.html b/docs/obs_3rd_party/python_sdk/obs_22_0911.html new file mode 100644 index 000000000..48c4f310d --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0911.html @@ -0,0 +1,1093 @@ + + +

Downloading an Object - Range-Based (SDK for Python)

+

Function

This API downloads partial data of an object by specifying a range. If the specified range is from 0 to 1,000, data from byte 0 to byte 1,000, 1,001 bytes in total, are returned. If the specified range is invalid, data of the whole object is returned.

+
+

Restrictions

+
+

Method

ObsClient.getObject(bucketName, objectKey, downloadPath, getObjectRequest, headers, loadStreamInMemory, progressCallback, extensionHeaders)
+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

str

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

downloadPath

+

str

+

No

+

Explanation:

+

The download path with the file name contained, for example, aa/bb.txt.

+

Default value:

+

None

+

getObjectRequest

+

GetObjectRequest

+

No

+

Explanation:

+

Additional parameters of an object download request

+

Value range:

+

See Table 2.

+

headers

+

GetObjectHeader

+

No

+

Explanation:

+

Additional headers of an object download request

+

Value range:

+

See Table 3.

+

loadStreamInMemory

+

bool

+

No

+

Explanation:

+

Whether to load the data stream of the object to memory

+

Value range:

+

True: The obtained data stream is loaded to memory with downloadPath ignored.

+

False: The obtained data stream is not loaded to memory.

+

Default value:

+

False

+

progressCallback

+

callable

+

No

+

Explanation:

+

Callback function for obtaining the download progress

+

Default value:

+

None

+
NOTE:

This function contains the following parameters in sequence: number of downloaded bytes, total number of bytes, and used time (in seconds). For details about the sample code, see Downloading an Object - Obtaining the Download Progress (SDK for Python).

+
+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 GetObjectRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

cache_control

+

str

+

No

+

Explanation:

+

Cache-Control is rewritten in the response.

+

Default value:

+

None

+

content_disposition

+

str

+

No

+

Explanation:

+

Content-Disposition is rewritten in the response.

+

Default value:

+

None

+

content_encoding

+

str

+

No

+

Explanation:

+

Content-Encoding is rewritten in the response.

+

Default value:

+

None

+

content_language

+

str

+

No

+

Explanation:

+

Content-Language is rewritten in the response.

+

Default value:

+

None

+

content_type

+

str

+

No

+

Explanation:

+

Content-Type is rewritten in the response.

+

Default value:

+

None

+

expires

+

str

+

No

+

Explanation:

+

Expires is rewritten in the response.

+

Default value:

+

None

+

versionId

+

str

+

No

+

Explanation:

+

Object version ID, for example, G001117FCE89978B0000401205D5DC9

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None. If this parameter is left blank, the latest version of the object is obtained.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 GetObjectHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

range

+

str

+

No

+

Explanation:

+

Download range

+

Value range:

+

0 to the object length minus 1. Format: x-y

+

Restrictions:

+

The upper limit of range is the length of the object minus 1. If the specified value exceeds this limit, the length of the object minus 1 is used.

+

Default value:

+

None

+

if_match

+

str

+

No

+

Explanation:

+

Preset ETag. If the ETag of the object to be downloaded is the same as the preset ETag, the object is returned. Otherwise, an error is returned.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

if_none_match

+

str

+

No

+

Explanation:

+

Preset ETag. If the ETag of the object to be downloaded is different from the preset ETag, the object is returned. Otherwise, an error is returned.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

if_modified_since

+

str

+

or

+

DateTime

+

No

+

Explanation:

+

The object is returned if it has been modified since the specified time; otherwise, an error is returned.

+

Restrictions:

+

You can generate a date time by referring to Table 4.

+

For example, DateTime(year=2023, month=9, day=12)

+

Default value:

+

None

+

if_unmodified_since

+

str

+

or

+

DateTime

+

No

+

Explanation:

+

The object is returned if it has not been modified since the specified time; otherwise, an error is returned.

+

Restrictions:

+

You can generate a date time by referring to Table 4.

+

For example, DateTime(year=2023, month=9, day=12)

+

Default value:

+

None

+

origin

+

str

+

No

+

Explanation:

+

Origin of the cross-domain request specified by the preflight request. Generally, it is a domain name.

+

Restrictions:

+

Each origin can contain only one wildcard character (*).

+

Default value:

+

None

+

requestHeaders

+

str

+

No

+

Explanation:

+

HTTP headers in a cross-origin request. Only CORS requests matching the allowed headers are valid.

+

Restrictions:

+

Each header can contain only one wildcard character (*). Spaces, ampersands (&), colons (:), and less-than signs (<) are not allowed.

+

Default value:

+

None

+

sseHeader

+

SseCHeader

+

No

+

Explanation:

+

Server-side decryption headers. For details, see Table 5.

+

Restrictions:

+

If the object uploaded to the server is encrypted on the server using the encryption key provided by the client, downloading the object requires including the encryption key in the message.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 4 DateTime

Parameter

+

Type

+

Description

+

year

+

int

+

Explanation:

+

Year in UTC

+

Default value:

+

None

+

month

+

int

+

Explanation:

+

Month in UTC

+

Default value:

+

None

+

day

+

int

+

Explanation:

+

Day in UTC

+

Default value:

+

None

+

hour

+

int

+

Explanation:

+

Hour in UTC

+

Restrictions:

+

The value is in 24-hour format.

+

Default value:

+

0

+

min

+

int

+

Explanation:

+

Minute in UTC

+

Default value:

+

0

+

sec

+

int

+

Explanation:

+

Second in UTC

+

Default value:

+

0

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 5 SseCHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

encryption

+

str

+

Yes

+

Explanation:

+

SSE-C used for encrypting objects

+

Value range:

+

AES256

+

Default value:

+

None

+

key

+

str

+

Yes

+

Explanation:

+

Key used in SSE-C encryption. It corresponds to the encryption method. For example, if encryption is set to AES256, the key is calculated using the AES-256 algorithm.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+
+
+
+

List of returned results

+
+ + + + + + + +
Table 6 List of returned results

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 7 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + +
Table 8 GetResult.body

GetResult.body Type

+

Description

+

ObjectStream

+

Explanation:

+

Response to the request for downloading an object

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 9 ObjectStream

Parameter

+

Type

+

Description

+

response

+

object

+

Explanation:

+

If loadStreamInMemory is set to False and downloadPath is left blank in the request, this parameter is returned and indicates a readable stream. You can read object content from it.

+

buffer

+

object

+

Explanation:

+

If loadStreamInMemory is set to True in the request, this parameter is returned and indicates the data stream in the memory.

+

size

+

int

+

Explanation:

+

If loadStreamInMemory is set to True in the request, this parameter is returned and indicates the size of the data stream.

+

Value range:

+

0 to (263 – 1), in bytes

+

url

+

str

+

Explanation:

+

If loadStreamInMemory is set to False and downloadPath is not left blank, this parameter is returned and indicates the download path.

+

deleteMarker

+

bool

+

Explanation:

+

Whether the deleted object is a delete marker

+

Value range:

+
  • True: The deleted object is a delete marker.
  • False: The deleted object is not a delete marker.
+

Default value:

+

False

+

storageClass

+

str

+

Explanation:

+

Object storage class.

+

Value range:

+
  • If the storage class is Standard, leave this parameter blank.
  • For details about the available storage classes, see Table 10.
+

Default value:

+

None

+

accessContorlAllowOrigin

+

str

+

Explanation:

+

If Origin in the request meets the CORS rules of the bucket, AllowedOrigin specified in the CORS rules is returned. AllowedOrigin indicates the origin from which the requests can access the bucket.

+

Restrictions:

+

Domain name of the origin. Each origin can contain only one wildcard character (*), for example, https://*.vbs.example.com.

+

Default value:

+

None

+

accessContorlAllowHeaders

+

str

+

Explanation:

+

If RequestHeader in the request meets the CORS rules of the bucket, AllowedHeader specified in the CORS rules is returned. AllowedHeader indicates the allowed headers for cross-origin requests. Only CORS requests matching the allowed headers are valid.

+

Restrictions:

+

Each header can contain only one wildcard character (*). Spaces, ampersands (&), colons (:), and less-than signs (<) are not allowed.

+

Default value:

+

None

+

accessContorlAllowMethods

+

str

+

Explanation:

+

AllowedMethod in the CORS rules of the bucket. It specifies the HTTP method of cross-origin requests, that is, the operation type of buckets and objects.

+

Value range:

+

The following HTTP methods are supported:

+
  • GET
  • PUT
  • HEAD
  • POST
  • DELETE
+

Default value:

+

None

+

accessContorlExposeHeaders

+

str

+

Explanation:

+

ExposeHeader in the CORS rules of the bucket. It specifies the CORS-allowed additional headers in the response. These headers provide additional information to clients. By default, your browser can only access headers Content-Length and Content-Type. If your browser needs to access other headers, add them to a list of the allowed additional headers.

+

Restrictions:

+

Spaces, wildcard characters (*), ampersands (&), colons (:), and less-than signs (<) are not allowed.

+

Default value:

+

None

+

accessContorlMaxAge

+

int

+

Explanation:

+

MaxAgeSeconds in the CORS rules of the bucket. It specifies the time your client can cache the response for a cross-origin request.

+

Restrictions:

+

Each CORS rule can contain only one MaxAgeSeconds.

+

Value range:

+

0 to (231 – 1), in seconds

+

Default value:

+

100

+

contentLength

+

int

+

Explanation:

+

Object size

+

Value range:

+

The value ranges from 0 TB to 48.8 TB, in bytes.

+

Default value:

+

None

+

cacheControl

+

str

+

Explanation:

+

Cache-Control header in the response

+

Default value:

+

None

+

contentDisposition

+

str

+

Explanation:

+

Content-Disposition header in the response

+

Default value:

+

None

+

contentEncoding

+

str

+

Explanation:

+

Content-Encoding header in the response

+

Default value:

+

None

+

contentLanguage

+

str

+

Explanation:

+

Content-Language header in the response

+

Default value:

+

None

+

contentType

+

str

+

Explanation:

+

MIME type of the file to be uploaded. MIME type is a standard way of describing a data type and is used by the browser to decide how to display data.

+

Value range:

+

See What Is Content-Type (MIME)? (Python SDK)

+

Default value:

+

None

+

expires

+

str

+

Explanation:

+

Expires header in the response

+

Default value:

+

None

+

lastModified

+

str

+

Explanation:

+

Time when the last modification was made to the object

+

Restrictions:

+

The time must be in the GMT format, for example, Wed, 25 Mar 2020 02:39:52 GMT.

+

Default value:

+

None

+

etag

+

str

+

Explanation:

+

Base64-encoded, 128-bit MD5 value of an object. ETag is the unique identifier of the object contents and is used to determine whether the contents of an object are changed. For example, if the ETag value is A when an object is uploaded and is B when the object is downloaded, this indicates the contents of the object are changed. The ETag reflects changes only to the contents of an object, not its metadata. Objects created by the upload and copy operations have unique ETags after being encrypted using MD5.

+

Restrictions:

+

If an object is encrypted using server-side encryption, the ETag is not the MD5 value of the object.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

versionId

+

str

+

Explanation:

+

Object version ID.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

restore

+

str

+

Explanation:

+

Restore status of an object. This header is returned when a Cold object is being restored or has been restored.

+

For example, ongoing-request="true" indicates that the object is being restored. ongoing-request="false", expiry-date="Wed, 7 Nov 2012 00:00:00 GMT" indicates that the object has been restored. expiry-date indicates when the restored object expires.

+

Restrictions:

+

If the object is not in the Cold storage class, this parameter is left blank.

+

Default value:

+

None

+

expiration

+

str

+

Explanation:

+

Expiration details. Example: "expiry-date=\"Mon, 11 Sep 2023 00:00:00 GMT\""

+

Default value:

+

None

+

sseKms

+

str

+

Explanation:

+

Objects are encrypted using SSE-KMS on the server side.

+

Value range:

+

kms

+

Default value:

+

None

+

sseKmsKey

+

str

+

Explanation:

+

ID of the KMS master key when SSE-KMS is used

+

Value range:

+

Valid value formats are as follows:

+
  1. regionID:domainID:key/key_id
  2. key_id
+

In the preceding formats:

+ +

Default value:

+
  • If this parameter is not specified, the default master key will be used.
  • If there is no such a default master key, the system will create one and use it by default.
+

sseC

+

str

+

Explanation:

+

SSE-C algorithm

+

Value range:

+

AES256

+

Default value:

+

None

+

sseCKeyMd5

+

str

+

Explanation:

+

MD5 value of the key for encrypting objects when SSE-C is used. This value is used to check whether any error occurs during the transmission of the key.

+

Restrictions:

+

The value is encrypted by MD5 and then encoded by Base64, for example, 4XvB3tbNTN+tIEVa0/fGaQ==.

+

Default value:

+

None

+

websiteRedirectLocation

+

str

+

Explanation:

+

If the bucket is configured with website hosting, the request for obtaining the object can be redirected to another object in the bucket or an external URL. This parameter specifies the address the request for the object is redirected to.

+

The request is redirected to object anotherPage.html in the same bucket:

+

WebsiteRedirectLocation:/anotherPage.html

+

The request is redirected to an external URL http://www.example.com/:

+

WebsiteRedirectLocation:http://www.example.com/

+

OBS obtains the specified value from the header and stores it in the object metadata WebsiteRedirectLocation.

+

Restrictions:

+
  • The value must start with a slash (/), http://, or https:// and cannot exceed 2 KB.
  • OBS only supports redirection for objects in the root directory of a bucket.
+

Default value:

+

None

+
+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 10 StorageClass

Parameter

+

Type

+

Description

+

STANDARD

+

Standard storage class

+

Explanation:

+

Features low access latency and high throughput and is used for storing massive, frequently accessed (multiple times a month) or small objects (< 1 MB) requiring quick response.

+

WARM

+

Warm storage class

+

Explanation:

+

Used for storing data that is semi-frequently accessed (fewer than 12 times a year) but is instantly available when needed.

+

COLD

+

Cold storage class

+

Explanation:

+

Used for storing rarely accessed (once a year) data.

+
+
+

Code Examples

This example downloads part of object objectname by specifying a range from 0 to 1,000.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
from obs import GetObjectHeader
+from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    # Specify the additional headers of the request for downloading an object.
+    headers = GetObjectHeader()
+    # Specify the range (0-1000 as an example) of the object bytes to be returned.
+    headers.range = '0-1000'
+    bucketName = "examplebucket"
+    objectKey = "objectname"
+    # Perform the range download. If loadStreamInMemory is set to True, downloadpath will be invalid, and data streams will be downloaded to the memory.
+    resp = obsClient.getObject(bucketName, objectKey, loadStreamInMemory=True, headers=headers)
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Get Object Succeeded')
+        print('requestId:', resp.requestId)
+        # Obtain the object content.
+        print('buffer:', resp.body.buffer)
+    else:
+        print('Get Object Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except: 
+    print('Get Object Failed')
+    print(traceback.format_exc())
+
+
+
  • If the specified range is invalid (for example, the start or end position is set to a negative integer or the range is larger than the object length), the whole object is returned.
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0912.html b/docs/obs_3rd_party/python_sdk/obs_22_0912.html new file mode 100644 index 000000000..fc70b3fa4 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0912.html @@ -0,0 +1,971 @@ + + +

Downloading an Object - Resumable (SDK for Python)

+

Function

Downloading large files often fails due to unstable network or program breakdown. It is a waste of resources to download files again. Moreover, the restarted download may still fail due to an unstable network. To resolve such issues, the resumable download API splits the file to be downloaded into multiple parts and downloads them separately. The download result of each part is recorded in a checkpoint file in real time. Only when all parts are downloaded is a message indicating the download is successful returned. If any parts fail to be downloaded, a message is returned telling you to call the API again to download the failed parts. Since the checkpoint file contains the progress of all parts, it helps you avoid downloading all parts in re-downloads, so that you can enjoy a cost-effective, efficient download.

+
+

Restrictions

+ +
+

Method

ObsClient.downloadFile(bucketName, objectKey, downloadFile, partSize, taskNum, enableCheckpoint, checkpointFile, header, versionId, progressCallback, extensionHeaders)
+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

str

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

downloadFile

+

str

+

Yes

+

Explanation:

+

Full local path for saving the file to be downloaded

+

Default value:

+

None

+

partSize

+

int

+

No

+

Explanation:

+

Part size

+

Value range:

+

The value must be greater than 0 but less than the object size, in bytes.

+

Default value:

+

5MB

+

taskNum

+

int

+

No

+

Explanation:

+

Maximum number of parts that can be downloaded concurrently in a multipart download

+

Value range:

+

The value must be greater than 0 but not exceed the result of the file size divided by the part size (rounded up).

+

Default value:

+

1, indicating concurrent downloads are not used.

+

enableCheckpoint

+

bool

+

No

+

Explanation:

+

Whether to enable the resumable download mode

+

Value range:

+

True: The resumable download mode is enabled.

+

False: The resumable download mode is disabled.

+

Default value:

+

False

+

checkpointFile

+

str

+

No

+

Explanation:

+

Path of a file generated for recording the progress of a resumable download. The file contains the information about parts and progress.

+

Restrictions:

+

This parameter is valid only for resumable uploads.

+

Default value:

+

If this parameter is left blank, the checkpoint file will be saved in the current directory.

+

header

+

GetObjectHeader

+

No

+

Explanation:

+

Headers in the request used for obtaining the storage class, redundancy policy, and other basic information about the object

+

Value range:

+

See Table 2.

+

Default value:

+

None

+

versionId

+

str

+

No

+

Explanation:

+

Object version ID, for example, G001117FCE89978B0000401205D5DC9

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None. If this parameter is left blank, the latest version of the object is obtained.

+

progressCallback

+

callable

+

No

+

Explanation:

+

Callback function for obtaining the download progress

+

Default value:

+

None

+
NOTE:

This function contains the following parameters in sequence: number of downloaded bytes, total number of bytes, and used time (in seconds). For details about the sample code, see Downloading an Object - Obtaining the Download Progress (SDK for Python).

+
+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 GetObjectHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

range

+

str

+

No

+

Explanation:

+

Download range. For example, 0-999 indicates the download range is from byte 1 to byte 1,000.

+

Value range:

+

Value range: 0 to the object length minus 1. Format: x-y, indicating the range is from byte x+1 to byte y+1

+

Restrictions:

+

The upper limit of range is the length of the object minus 1. If the specified value exceeds this limit, the length of the object minus 1 is used.

+

Default value:

+

None

+

if_match

+

str

+

No

+

Explanation:

+

Preset ETag. If the ETag of the object to be downloaded is the same as the preset ETag, the object is returned. Otherwise, an error is returned.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

if_none_match

+

str

+

No

+

Explanation:

+

Preset ETag. If the ETag of the object to be downloaded is different from the preset ETag, the object is returned. Otherwise, an error is returned.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

if_modified_since

+

str

+

or

+

DateTime

+

No

+

Explanation:

+

The object is returned if it has been modified since the specified time; otherwise, an error is returned.

+

Restrictions:

+

The value must be in the GMT format. For example, Wed, 25 Mar 2020 02:39:52 GMT. You can refer to Table 3 to specify time.

+

For example, DateTime(year=2023, month=9, day=12)

+

Default value:

+

None

+

if_unmodified_since

+

str

+

or

+

DateTime

+

No

+

Explanation:

+

The object is returned if it has not been modified since the specified time; otherwise, an error is returned.

+

Restrictions:

+

The value must be in the GMT format. For example, Wed, 25 Mar 2020 02:39:52 GMT. You can refer to Table 3 to specify time.

+

For example, DateTime(year=2023, month=9, day=12)

+

Default value:

+

None

+

origin

+

str

+

No

+

Explanation:

+

Origin of the cross-domain request specified by the preflight request. Generally, it is a domain name.

+

Restrictions:

+

Each origin can contain only one wildcard character (*).

+

Default value:

+

None

+

requestHeaders

+

str

+

No

+

Explanation:

+

HTTP headers in a cross-origin request Only CORS requests matching the allowed headers are valid.

+

Restrictions:

+

Each header can contain only one wildcard character (*). Spaces, ampersands (&), colons (:), and less-than signs (<) are not allowed.

+

Default value:

+

None

+

sseHeader

+

SseCHeader

+

No

+

Explanation:

+

Server-side decryption headers. For details, see Table 4.

+

Restrictions:

+

If the object uploaded to the server is encrypted on the server using the encryption key provided by the client, downloading the object requires including the encryption key in the message.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 DateTime

Parameter

+

Type

+

Description

+

year

+

int

+

Explanation:

+

Year in UTC

+

Default value:

+

None

+

month

+

int

+

Explanation:

+

Month in UTC

+

Default value:

+

None

+

day

+

int

+

Explanation:

+

Day in UTC

+

Default value:

+

None

+

hour

+

int

+

Explanation:

+

Hour in UTC

+

Restrictions:

+

The value is in 24-hour format.

+

Default value:

+

0

+

min

+

int

+

Explanation:

+

Minute in UTC

+

Default value:

+

0

+

sec

+

int

+

Explanation:

+

Second in UTC

+

Default value:

+

0

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 4 SseCHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

encryption

+

str

+

Yes

+

Explanation:

+

SSE-C used for encrypting objects

+

Value range:

+

AES256

+

Default value:

+

None

+

key

+

str

+

Yes

+

Explanation:

+

Key used in SSE-C encryption. It corresponds to the encryption method. For example, if encryption is set to AES256, the key is calculated using the AES-256 algorithm.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + +
Table 5 List of returned results

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 6 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + +
Table 7 GetResult.body

GetResult.body Type

+

Description

+

GetObjectMetadataResponse

+

Explanation:

+

For details, see Table 8.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 8 GetObjectMetadataResponse

Parameter

+

Type

+

Description

+

storageClass

+

str

+

Explanation:

+

Object storage class.

+

Value range:

+
  • If the storage class is Standard, leave this parameter blank.
  • For details about the available storage classes, see Table 9.
+

Default value:

+

None

+

accessContorlAllowOrigin

+

str

+

Explanation:

+

If Origin in the request meets the CORS rules of the bucket, AllowedOrigin specified in the CORS rules is returned. AllowedOrigin indicates the origin from which the requests can access the bucket.

+

Restrictions:

+

Domain name of the origin. Each origin can contain only one wildcard character (*), for example, https://*.vbs.example.com.

+

Default value:

+

None

+

accessContorlAllowHeaders

+

str

+

Explanation:

+

If RequestHeader in the request meets the CORS rules of the bucket, AllowedHeader specified in the CORS rules is returned. AllowedHeader indicates the allowed headers for cross-origin requests. Only CORS requests matching the allowed headers are valid.

+

Restrictions:

+

Each header can contain only one wildcard character (*). Spaces, ampersands (&), colons (:), and less-than signs (<) are not allowed.

+

Default value:

+

None

+

accessContorlAllowMethods

+

str

+

Explanation:

+

AllowedMethod in the CORS rules of the bucket. It specifies the HTTP method of cross-origin requests, that is, the operation type of buckets and objects.

+

Value range:

+

The following HTTP methods are supported:

+
  • GET
  • PUT
  • HEAD
  • POST
  • DELETE
+

Default value:

+

None

+

accessContorlExposeHeaders

+

str

+

Explanation:

+

ExposeHeader in the CORS rules of the bucket. It specifies the CORS-allowed additional headers in the response. These headers provide additional information to clients. By default, your browser can only access headers Content-Length and Content-Type. If your browser needs to access other headers, add them to a list of the allowed additional headers.

+

Restrictions:

+

Spaces, wildcard characters (*), ampersands (&), colons (:), and less-than signs (<) are not allowed.

+

Default value:

+

None

+

accessContorlMaxAge

+

int

+

Explanation:

+

MaxAgeSeconds in the CORS rules of the bucket. It specifies the time your client can cache the response for a cross-origin request.

+

Restrictions:

+

Each CORS rule can contain only one MaxAgeSeconds.

+

Value range:

+

An integer greater than or equal to 0, in seconds

+

Default value:

+

100

+

contentLength

+

int

+

Explanation:

+

Object size

+

Value range:

+

The value ranges from 0 TB to 48.8 TB, in bytes.

+

Default value:

+

None

+

contentType

+

str

+

Explanation:

+

MIME type of the object to be downloaded. MIME type is a standard way of describing a data type and is used by the browser to decide how to display data.

+

Value range:

+

See What Is Content-Type (MIME)? (Python SDK)

+

Default value:

+

None

+

lastModified

+

str

+

Explanation:

+

Time when the last modification was made to the object

+

Restrictions:

+

The time must be in the GMT format, for example, Wed, 25 Mar 2020 02:39:52 GMT.

+

Default value:

+

None

+

etag

+

str

+

Explanation:

+

Base64-encoded, 128-bit MD5 value of an object. ETag is the unique identifier of the object contents and is used to determine whether the contents of an object are changed. For example, if the ETag value is A when an object is uploaded and is B when the object is downloaded, this indicates the contents of the object are changed. The ETag reflects changes only to the contents of an object, not its metadata. Objects created by the upload and copy operations have unique ETags after being encrypted using MD5.

+

Restrictions:

+

If an object is encrypted using server-side encryption, the ETag is not the MD5 value of the object.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

versionId

+

str

+

Explanation:

+

Object version ID.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

restore

+

str

+

Explanation:

+

Restore status of an object. This header is returned when a Cold object is being restored or has been restored.

+

For example, ongoing-request="true" indicates that the object is being restored. ongoing-request="false", expiry-date="Wed, 7 Nov 2012 00:00:00 GMT" indicates that the object has been restored. expiry-date indicates when the restored object expires.

+

Restrictions:

+

This parameter is only available for Cold objects.

+

Default value:

+

None

+

expiration

+

str

+

Explanation:

+

Expiration details. Example: "expiry-date=\"Mon, 11 Sep 2023 00:00:00 GMT\""

+

Default value:

+

None

+

sseKms

+

str

+

Explanation:

+

SSE-KMS is used for encrypting objects on the server side.

+

Value range:

+

kms

+

Default value:

+

None

+

sseKmsKey

+

str

+

Explanation:

+

ID of the KMS master key when SSE-KMS is used

+

Value range:

+

Valid value formats are as follows:

+
  1. regionID:domainID:key/key_id
  2. key_id
+

In the preceding formats:

+ +

Default value:

+
  • If this parameter is not specified, the default master key will be used.
  • If there is no such a default master key, the system will create one and use it by default.
+

sseC

+

str

+

Explanation:

+

SSE-C algorithm

+

Value range:

+

AES256

+

Default value:

+

None

+

sseCKeyMd5

+

str

+

Explanation:

+

MD5 value of the key for encrypting objects when SSE-C is used. This value is used to check whether any error occurs during the transmission of the key.

+

Restrictions:

+

The value is encrypted by MD5 and then encoded by Base64, for example, 4XvB3tbNTN+tIEVa0/fGaQ==.

+

Default value:

+

None

+

websiteRedirectLocation

+

str

+

Explanation:

+

If the bucket is configured with website hosting, the request for obtaining the object can be redirected to another object in the bucket or an external URL. This parameter specifies the address the request for the object is redirected to.

+

The request is redirected to object anotherPage.html in the same bucket:

+

WebsiteRedirectLocation:/anotherPage.html

+

The request is redirected to an external URL http://www.example.com/:

+

WebsiteRedirectLocation:http://www.example.com/

+

OBS obtains the specified value from the header and stores it in the object metadata WebsiteRedirectLocation.

+

Restrictions:

+
  • The value must start with a slash (/), http://, or https:// and cannot exceed 2 KB.
  • OBS only supports redirection for objects in the root directory of a bucket.
+

Default value:

+

None

+

isAppendable

+

bool

+

Explanation:

+

Whether the object is appendable

+

Value range:

+

True: The object is appendable.

+

False: The object is not appendable.

+

Default value:

+

None

+

nextPosition

+

int

+

Explanation:

+

Start position for next appending

+

Value range:

+

0 to the object length, in bytes.

+

Default value:

+

None

+
+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 9 StorageClass

Parameter

+

Type

+

Description

+

STANDARD

+

Standard storage class

+

Explanation:

+

Features low access latency and high throughput and is used for storing massive, frequently accessed (multiple times a month) or small objects (< 1 MB) requiring quick response.

+

WARM

+

Warm storage class

+

Explanation:

+

Used for storing data that is semi-frequently accessed (fewer than 12 times a year) but is instantly available when needed.

+

COLD

+

Cold storage class

+

Explanation:

+

Used for storing rarely accessed (once a year) data.

+
+
+

Code Examples

This example downloads object objectname from bucket examplebucket using resumable download.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName = "examplebucket"
+    objectKey = "objectname"
+    # Specify the full path to which objects are downloaded. The full path contains the local file name.
+    downloadFile = 'localfile'
+    # Specify the number of parts that can be concurrently downloaded.
+    taskNum = 5
+    # Specify the part size.
+    partSize = 10 * 1024 * 1024
+    # Enable the resumable download by setting enableCheckpoint to True.
+    enableCheckpoint = True
+    # Download the object using resumable download.
+    resp = obsClient.downloadFile(bucketName, objectKey, downloadFile, partSize, taskNum, enableCheckpoint)
+
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Download File Succeeded')
+        print('requestId:', resp.requestId)
+    else:
+        print('Download File Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Download File Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0913.html b/docs/obs_3rd_party/python_sdk/obs_22_0913.html new file mode 100644 index 000000000..6adddf6ac --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0913.html @@ -0,0 +1,110 @@ + + +

Downloading an Object - Obtaining the Download Progress (SDK for Python)

+

You can obtain the download progress when downloading an object in binary, streaming, file-based, or resumable mode.

+

This example returns the object download progress.

+

Sample code is as follows:

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+
+# Obtain the download progress.
+def callback(transferredAmount, totalAmount, totalSeconds):
+    # Obtain the average download rate (KB/s).
+    print(transferredAmount * 1.0 / totalSeconds / 1024)
+    # Obtain the download progress in percentage.
+    print(transferredAmount * 100.0 / totalAmount)
+
+try:
+    bucketName="examplebucket"
+    objectKey="objectname"
+    # Download an object.
+    resp = obsClient.getObject(bucketName=bucketName,objectKey=objectKey, progressCallback=callback)
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Get Object Succeeded')
+        print('requestId:', resp.requestId)
+        # Read the object content.
+        while True:
+            chunk = resp.body.response.read(65536)
+            if not chunk:
+                break
+            print(chunk)
+        resp.body.response.close()
+    else:
+        print('Get Object Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Get Object Failed')
+    print(traceback.format_exc())
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0915.html b/docs/obs_3rd_party/python_sdk/obs_22_0915.html new file mode 100644 index 000000000..7aacd3d46 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0915.html @@ -0,0 +1,913 @@ + + +

Uploading an Object - Creating a Folder (SDK for Python)

+

Function

This API creates a folder in an existing bucket to manage data in OBS.

+

OBS does not involve folders like in a file system. All elements stored in OBS buckets are objects. To create a folder in OBS is essentially to create an object whose size is 0 and whose name ends with a slash (/). Such objects are no different from other objects (you can perform normal operations on them such as download and delete), except that they are displayed as folders in OBS console.

+
+

Restrictions

+
+

Method

ObsClient.putContent(bucketName, objectKey, content, metadata, headers, progressCallback, autoClose, extensionHeaders)
+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

str

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

content

+

str

+

or

+

readable object

+

No

+

Explanation:

+

Content of the object to be uploaded

+

Value range:

+

None

+

Default value:

+

None

+

metadata

+

dict

+

No

+

Explanation:

+

Custom metadata of the object to be uploaded. You can add a header starting with x-obs-meta- in the request to define metadata. The custom metadata will be returned in the response when you retrieve the object or query the object metadata.

+

Restrictions:

+
  • The custom metadata cannot exceed 8 KB. To measure the custom metadata, sum the number of bytes in the UTF-8 encoding of each key and value.
  • The custom metadata keys are case insensitive, but are stored in lowercase in OBS. The key values are case sensitive.
  • Both custom metadata keys and their values must conform to US-ASCII standards. If non-ASCII or unrecognizable characters are required, they must be encoded and decoded in URL or Base64 on the client, because the server does not perform such operations.
+

Default value:

+

None

+

headers

+

PutObjectHeader

+

No

+

Explanation:

+

Headers in the request used for configuring the storage class, redundancy policy, and other basic information about the object

+

Value range:

+

See Table 2.

+

Default value:

+

None

+

progressCallback

+

callable

+

No

+

Explanation:

+

Callback function for obtaining the upload progress

+

Default value:

+

None

+
NOTE:

This function contains the following parameters in sequence: number of uploaded bytes, total number of bytes, and used time (in seconds). For details about the sample code, see Obtaining the Upload Progress (SDK for Python).

+

Streaming uploads, file-based uploads, multipart uploads, appendable uploads, and resumable uploads are supported.

+
+

autoClose

+

bool

+

No

+

Explanation:

+

Whether or not to automatically close data streams after the upload is complete

+

Value range:

+

True: The data stream is automatically closed.

+

False: The data stream is not automatically closed.

+

Default value:

+

True

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 PutObjectHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

md5

+

str

+

No

+

Explanation:

+

Base64-encoded MD5 value of the data to be uploaded. It is used for the OBS server to verify data integrity.

+

Value range:

+

Base64-encoded 128-bit MD5 value of the request body calculated according to RFC 1864

+

Example: n58IG6hfM7vqI4K0vnWpog==

+

Default value:

+

None

+

acl

+

str

+

No

+

Explanation:

+

Pre-defined access policy specified during object creation.

+

Value range:

+

See Table 3.

+

Default value:

+

None

+

location

+

str

+

No

+

Explanation:

+

If the bucket is configured with website hosting, the request for obtaining the object can be redirected to another object in the bucket or an external URL.

+

The request is redirected to object anotherPage.html in the same bucket:

+

location:/anotherPage.html

+

The request is redirected to an external URL http://www.example.com/:

+

location:http://www.example.com/

+

OBS obtains the specified value from the header and stores it in the object metadata location.

+

Restrictions:

+
  • The value must start with a slash (/), http://, or https:// and cannot exceed 2 KB.
  • OBS only supports redirection for objects in the root directory of a bucket.
+

Default value:

+

None

+

contentType

+

str

+

No

+

Explanation:

+

MIME type of the file to be uploaded. MIME type is a standard way of describing a data type and is used by the browser to decide how to display data.

+

Value range:

+

See What Is Content-Type (MIME)? (Python SDK)

+

Default value:

+

If you do not specify contentType when uploading an object, the SDK determines the object type based on the suffix of the specified object name and automatically assigns a value to contentType.

+

contentLength

+

int

+

No

+

Explanation:

+

Size of the object to be uploaded

+

Restrictions:

+
  • The object size in a single upload ranges from 0 to 5 GB.
  • To upload files larger than 5 GB, multipart uploads should be used.
+

Default value:

+

If this parameter is not specified, OBS SDK for Python automatically calculates the size of the object.

+

sseHeader

+

SseCHeader

+

or

+

SseKmsHeader

+

No

+

Explanation:

+

Header for server-side encryption. For details, see Table 5 or Table 6.

+

Default value:

+

None

+

storageClass

+

str

+

No

+

Explanation:

+

Storage class of the object

+

Value range:

+

See Table 4.

+

Default value:

+

None

+

successActionRedirect

+

str

+

No

+

Explanation:

+

Address (URL) to which a successfully answered request is redirected

+
  • If the value is valid and the request is successful, OBS returns status code 303. Location in the returned results contains SuccessActionRedirect as well as the bucket name, object name, and object ETag.
  • If the value is invalid, OBS ignores this parameter. In such case, Location in the returned results indicates the object address, and OBS returns a status code based on whether the operation succeeds or fails.
+

Default value:

+

None

+

extensionGrants

+

list of ExtensionGrant

+

No

+

Explanation:

+

List of the extended permissions for the object to be uploaded

+

Value range:

+

See Table 7.

+

Default value:

+

None

+

expires

+

int

+

No

+

Explanation:

+

Expiration time of the object (calculated from the latest modification time of the object). Expired objects are automatically deleted.

+

Restrictions:

+

This parameter can be configured only when uploading the object. It cannot be modified by calling a metadata modification API.

+

Value range:

+

An integer greater than or equal to 0, in days

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 HeadPermission

Constant

+

Default Value

+

Description

+

HeadPermission.PRIVATE

+

private

+

Private read/write

+

A bucket or object can only be accessed by its owner.

+

HeadPermission.PUBLIC_READ

+

public-read

+

Public read and private write

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, metadata, and object versions in the bucket.

+

If it is granted on an object, anyone can read the content and metadata of the object.

+

HeadPermission.PUBLIC_READ_WRITE

+

public-read-write

+

Public read/write

+

If this permission is granted on a bucket, anyone can read the object list, multipart tasks, metadata, and object versions in the bucket, and can upload or delete objects, initiate multipart upload tasks, upload parts, assemble parts, copy parts, and abort multipart upload tasks.

+

If it is granted on an object, anyone can read the content and metadata of the object.

+

HeadPermission.PUBLIC_READ_DELIVERED

+

public-read-delivered

+

Public read on a bucket as well as objects in the bucket

+

If this permission is granted on a bucket, anyone can read the object list, multipart tasks, metadata, and object versions, and read the content and metadata of objects in the bucket.

+
NOTE:

PUBLIC_READ_DELIVERED cannot be applied to objects.

+
+

HeadPermission.PUBLIC_READ_WRITE_DELIVERED

+

public-read-write-delivered

+

Public read/write on a bucket as well as objects in the bucket

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, metadata, and object versions in the bucket, and can upload or delete objects, initiate multipart upload tasks, upload parts, assemble parts, copy parts, and abort multipart uploads. They can also read the content and metadata of objects in the bucket.

+
NOTE:

PUBLIC_READ_WRITE_DELIVERED cannot be applied to objects.

+
+

HeadPermission.BUCKET_OWNER_FULL_CONTROL

+

public-read-write-delivered

+

If this permission is granted on an object, only the bucket and object owners have the full control over the object. By default, if you upload an object to a bucket of any other user, the bucket owner does not have the permissions on your object. After you grant this policy to the bucket owner, the bucket owner can have full control over your object.

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 4 StorageClass

Parameter

+

Type

+

Description

+

STANDARD

+

Standard storage class

+

Explanation:

+

Features low access latency and high throughput and is used for storing massive, frequently accessed (multiple times a month) or small objects (< 1 MB) requiring quick response.

+

WARM

+

Warm storage class

+

Explanation:

+

Used for storing data that is semi-frequently accessed (fewer than 12 times a year) but is instantly available when needed.

+

COLD

+

Cold storage class

+

Explanation:

+

Used for storing rarely accessed (once a year) data.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 5 SseCHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

encryption

+

str

+

Yes

+

Explanation:

+

SSE-C used for encrypting objects

+

Value range:

+

AES256

+

Default value:

+

None

+

key

+

str

+

Yes

+

Explanation:

+

Key used in SSE-C encryption. It corresponds to the encryption method. For example, if encryption is set to AES256, the key is calculated using the AES-256 algorithm.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 6 SseKmsHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

encryption

+

str

+

Yes

+

Explanation:

+

SSE-KMS used for encrypting objects

+

Value range:

+

kms

+

Default value:

+

None

+

key

+

str

+

No

+

Explanation:

+

Master key used in SSE-KMS

+

Value range:

+

The following two formats are supported:

+
  • regionID:domainID:key/key_id
  • key_id
+

In the preceding formats:

+ +

Default value:

+
  • If this parameter is not specified, the default master key will be used.
  • If there is no such a default master key, OBS will create one and use it by default.
+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 7 ExtensionGrant

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

granteeId

+

str

+

No

+

Explanation:

+

Account (domain) ID of the grantee

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and IAM User ID? (SDK for Python)

+

Default value:

+

None

+

permission

+

str

+

No

+

Explanation:

+

Granted permissions

+

Default value:

+

None

+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
Table 8 Permission

Constant

+

Description

+

READ

+

Read permission

+

A grantee with this permission for a bucket can obtain the list of objects, multipart uploads, bucket metadata, and object versions in the bucket.

+

A grantee with this permission for an object can obtain the object content and metadata.

+

WRITE

+

Write permission

+

A grantee with this permission for a bucket can upload, overwrite, and delete any object or part in the bucket.

+

Such permission for an object is not applicable.

+

READ_ACP

+

Permission to read ACL configurations

+

A grantee with this permission can obtain the ACL of a bucket or object.

+

A bucket or object owner has this permission for the bucket or object permanently.

+

WRITE_ACP

+

Permission to modify ACL configurations

+

A grantee with this permission can update the ACL of a bucket or object.

+

A bucket or object owner has this permission for the bucket or object permanently.

+

A grantee with this permission can modify the access control policy and thus the grantee obtains full access permissions.

+

FULL_CONTROL

+

Full control access, including read and write permissions for a bucket and its ACL, or for an object and its ACL.

+

A grantee with this permission for a bucket has READ, WRITE, READ_ACP, and WRITE_ACP permissions for the bucket.

+

A grantee with this permission for an object has READ, READ_ACP, and WRITE_ACP permissions for the object.

+
+
+

Responses

+
+ + + + + + + +
Table 9 List of returned results

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 10 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + +
Table 11 GetResult.body

GetResult.body Type

+

Description

+

PutContentResponse

+

Explanation:

+

Response to the request for uploading an object. For details, see Table 12.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 12 PutContentResponse

Parameter

+

Type

+

Description

+

storageClass

+

str

+

Explanation:

+

Storage class of the object

+

Value range:

+
  • If the storage class is Standard, leave this parameter blank.
  • For details about the available storage classes, see Table 4.
+

Default value:

+

None

+

versionId

+

str

+

Explanation:

+

Object version ID. If versioning is enabled for the bucket, the object version ID will be returned.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

etag

+

str

+

Explanation:

+

Base64-encoded, 128-bit MD5 value of an object. ETag is the unique identifier of the object contents and is used to determine whether the contents of an object are changed. For example, if the ETag value is A when an object is uploaded and is B when the object is downloaded, this indicates the contents of the object are changed. The ETag reflects changes only to the contents of an object, not its metadata. Objects created by the upload and copy operations have unique ETags after being encrypted using MD5.

+

Restrictions:

+

If an object is encrypted using server-side encryption, the ETag is not the MD5 value of the object.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

sseKms

+

str

+

Explanation:

+

SSE-KMS algorithm

+

Value range:

+

kms

+

Default value:

+

None

+

sseKmsKey

+

str

+

Explanation:

+

ID of the KMS master key when SSE-KMS is used

+

Value range:

+

Valid value formats are as follows:

+
  1. regionID:domainID:key/key_id
  2. key_id
+

In the preceding formats:

+ +

Default value:

+
  • If this parameter is not specified, the default master key will be used.
  • If there is no such a default master key, the system will create one and use it by default.
+

sseC

+

str

+

Explanation:

+

SSE-C algorithm

+

Value range:

+

AES256

+

Default value:

+

None

+

sseCKeyMd5

+

str

+

Explanation:

+

MD5 value of the key for encrypting objects when SSE-C is used. This value is used to check whether any error occurs during the transmission of the key.

+

Restrictions:

+

The value is encrypted by MD5 and then encoded by Base64, for example, 4XvB3tbNTN+tIEVa0/fGaQ==.

+

Default value:

+

None

+

objectUrl

+

str

+

Explanation:

+

Full path to the object

+

Default value:

+

None

+
+
+
+

Code Examples

This example creates a folder named parent_directory/.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName = "examplebucket"
+    # Specify a folder name ending with a slash (/).
+    objectKey = "parent_directory/"
+    # Create a folder object whose name ends with a slash (/). To avoid unexpected charges, do not upload files to the folder during creation.
+    resp = obsClient.putContent(bucketName, objectKey, content=None)
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Put Content Succeeded')
+        print('requestId:', resp.requestId)
+    else:
+        print('Put Content Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Put Content Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0917.html b/docs/obs_3rd_party/python_sdk/obs_22_0917.html new file mode 100644 index 000000000..7170b5595 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0917.html @@ -0,0 +1,1128 @@ + + +

Copying an Object (SDK for Python)

+

Function

This API copies an object stored in OBS to another path, with a copy created during the process. You can create a copy of an object up to 5 GB in a single operation.

+
+

Restrictions

+
+

Method

ObsClient.copyObject(sourceBucketName, sourceObjectKey, destBucketName, destObjectKey, metadata, headers, versionId, extensionHeaders)
+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

sourceBucketName

+

str

+

Yes

+

Explanation:

+

Name of the source bucket

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

sourceObjectKey

+

str

+

Yes

+

Explanation:

+

Source object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

versionId

+

str

+

No

+

Explanation:

+

Version ID of the source object, for example, G001117FCE89978B0000401205D5DC9A

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

If this parameter is left blank, the latest version of the source object is copied.

+

destBucketName

+

str

+

Yes

+

Explanation:

+

Target bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

destObjectKey

+

str

+

Yes

+

Explanation:

+

Target object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

metadata

+

dict

+

No

+

Explanation:

+

Custom metadata of the target object You can add a header starting with x-obs-meta- in the request to define metadata. The custom metadata will be returned in the response when you retrieve the object or query the object metadata.

+

Restrictions:

+
  • You need to set directive in headers to REPLACE.
  • The custom metadata cannot exceed 8 KB. To measure the custom metadata, sum the number of bytes in the UTF-8 encoding of each key and value.
  • The custom metadata keys are case insensitive, but are stored in lowercase in OBS. The key values are case sensitive.
  • Both custom metadata keys and their values must conform to US-ASCII standards. If non-ASCII or unrecognizable characters are required, they must be encoded and decoded in URL or Base64 on the client, because the server does not perform such operations.
+

Default value:

+

None

+

headers

+

CopyObjectHeader

+

No

+

Explanation:

+

Request headers for copying an object. For details, see Table 2.

+

Default value:

+

None

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 CopyObjectHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

acl

+

str

+

No

+

Explanation:

+

Pre-defined access control policies, which can be specified when copying the object

+

Default value:

+

None

+

directive

+

str

+

No

+

Explanation:

+

Whether to copy source object attributes to the target object

+

Value range:

+
  • COPY (attributes of the target object are copied from the source object)
  • REPLACE (attributes of the target object are replaced with values specified in the request parameters)
+

Default value:

+

COPY

+

if_match

+

str

+

No

+

Explanation:

+

Preset ETag. If the ETag of the object to be downloaded is the same as the preset ETag, the object is returned. Otherwise, an error is returned.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

if_none_match

+

str

+

No

+

Explanation:

+

Preset ETag. If the ETag of the object to be downloaded is different from the preset ETag, the object is returned. Otherwise, an error is returned.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

if_modified_since

+

str

+

or

+

DateTime

+

No

+

Explanation:

+

The source object is copied if it has been modified since the specified time; otherwise, an exception is thrown.

+

Restrictions:

+

The value must be in the GMT format. For example, Wed, 25 Mar 2020 02:39:52 GMT. You can refer to Table 5 to specify time.

+

For example, DateTime(year=2023, month=9, day=12)

+

Default value:

+

None

+

if_unmodified_since

+

str

+

or

+

DateTime

+

No

+

Explanation:

+

The source object is copied if it has not been modified since the specified time; otherwise, an exception is thrown.

+

Restrictions:

+

The value must be in the GMT format. For example, Wed, 25 Mar 2020 02:39:52 GMT. You can refer to Table 5 to specify time.

+

For example, DateTime(year=2023, month=9, day=12)

+

Default value:

+

None

+

location

+

str

+

No

+

Explanation:

+

If the bucket is configured with website hosting, the request for obtaining the object can be redirected to another object in the bucket or an external URL.

+

The request is redirected to object anotherPage.html in the same bucket:

+

location:/anotherPage.html

+

The request is redirected to an external URL http://www.example.com/:

+

location:http://www.example.com/

+

OBS obtains the specified value from the header and stores it in the object metadata location.

+

Restrictions:

+
  • The value must start with a slash (/), http://, or https:// and cannot exceed 2 KB.
  • OBS only supports redirection for objects in the root directory of a bucket.
+

Default value:

+

None

+

destSseHeader

+

SseCHeader

+

or

+

SseKmsHeader

+

No

+

Explanation:

+

Header for server-side encryption. It is used to encrypt the target object.

+

Value range:

+

See Table 6 or Table 7.

+

Default value:

+

None

+

sourceSseHeader

+

SseCHeader

+

No

+

Explanation:

+

Header for server-side decryption. It is used to decrypt the source object.

+

Value range:

+

See Table 6.

+

Default value:

+

None

+

cacheControl

+

str

+

No

+

Explanation:

+

Cache-Control is rewritten in the response.

+

Default value:

+

None

+

contentDisposition

+

str

+

No

+

Explanation:

+

Content-Disposition is rewritten in the response.

+

Default value:

+

None

+

contentEncoding

+

str

+

No

+

Explanation:

+

Content-Encoding is rewritten in the response.

+

Default value:

+

None

+

contentLanguage

+

str

+

No

+

Explanation:

+

Content-Language is rewritten in the response.

+

Default value:

+

None

+

contentType

+

str

+

No

+

Explanation:

+

MIME type of the file to be uploaded. MIME type is a standard way of describing a data type and is used by the browser to decide how to display data.

+

Value range:

+

See What Is Content-Type (MIME)? (Python SDK)

+

Default value:

+

None

+

expires

+

str

+

No

+

Explanation:

+

Expiration details. Example: "expiry-date=\"Mon, 11 Sep 2023 00:00:00 GMT\""

+

Default value:

+

None

+

storageClass

+

str

+

No

+

Explanation:

+

Object storage class.

+

Value range:

+
  • If the storage class is Standard, leave this parameter blank.
  • For details about the available storage classes, see Table 4.
+

Default value:

+

None

+

successActionRedirect

+

str

+

No

+

Explanation:

+

Address (URL) to which a successfully answered request is redirected

+
  • If the value is valid and the request is successful, OBS returns status code 303. Location in the returned results contains SuccessActionRedirect as well as the bucket name, object name, and object ETag.
  • If the value is invalid, OBS ignores this parameter. In such case, Location in the returned results indicates the object address, and OBS returns a status code based on whether the operation succeeds or fails.
+

Default value:

+

None

+

extensionGrants

+

list of ExtensionGrant

+

No

+

Explanation:

+

List of the extended permissions for the object

+

Value range:

+

See Table 8.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 HeadPermission

Constant

+

Default Value

+

Description

+

HeadPermission.PRIVATE

+

private

+

Private read/write

+

A bucket or object can only be accessed by its owner.

+

HeadPermission.PUBLIC_READ

+

public-read

+

Public read and private write

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, metadata, and object versions in the bucket.

+

If it is granted on an object, anyone can read the content and metadata of the object.

+

HeadPermission.PUBLIC_READ_WRITE

+

public-read-write

+

Public read/write

+

If this permission is granted on a bucket, anyone can read the object list, multipart tasks, metadata, and object versions in the bucket, and can upload or delete objects, initiate multipart upload tasks, upload parts, assemble parts, copy parts, and abort multipart upload tasks.

+

If it is granted on an object, anyone can read the content and metadata of the object.

+

HeadPermission.PUBLIC_READ_DELIVERED

+

public-read-delivered

+

Public read on a bucket as well as objects in the bucket

+

If this permission is granted on a bucket, anyone can read the object list, multipart tasks, metadata, and object versions, and read the content and metadata of objects in the bucket.

+
NOTE:

PUBLIC_READ_DELIVERED cannot be applied to objects.

+
+

HeadPermission.PUBLIC_READ_WRITE_DELIVERED

+

public-read-write-delivered

+

Public read/write on a bucket as well as objects in the bucket

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, metadata, and object versions in the bucket, and can upload or delete objects, initiate multipart upload tasks, upload parts, assemble parts, copy parts, and abort multipart uploads. They can also read the content and metadata of objects in the bucket.

+
NOTE:

PUBLIC_READ_WRITE_DELIVERED cannot be applied to objects.

+
+

HeadPermission.BUCKET_OWNER_FULL_CONTROL

+

public-read-write-delivered

+

If this permission is granted on an object, only the bucket and object owners have the full control over the object. By default, if you upload an object to a bucket of any other user, the bucket owner does not have the permissions on your object. After you grant this policy to the bucket owner, the bucket owner can have full control over your object.

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 4 StorageClass

Parameter

+

Type

+

Description

+

STANDARD

+

Standard storage class

+

Explanation:

+

Features low access latency and high throughput and is used for storing massive, frequently accessed (multiple times a month) or small objects (< 1 MB) requiring quick response.

+

WARM

+

Warm storage class

+

Explanation:

+

Used for storing data that is semi-frequently accessed (fewer than 12 times a year) but is instantly available when needed.

+

COLD

+

Cold storage class

+

Explanation:

+

Used for storing rarely accessed (once a year) data.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 5 DateTime

Parameter

+

Type

+

Description

+

year

+

int

+

Explanation:

+

Year in UTC

+

Default value:

+

None

+

month

+

int

+

Explanation:

+

Month in UTC

+

Default value:

+

None

+

day

+

int

+

Explanation:

+

Day in UTC

+

Default value:

+

None

+

hour

+

int

+

Explanation:

+

Hour in UTC

+

Restrictions:

+

The value is in 24-hour format.

+

Default value:

+

0

+

min

+

int

+

Explanation:

+

Minute in UTC

+

Default value:

+

0

+

sec

+

int

+

Explanation:

+

Second in UTC

+

Default value:

+

0

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 6 SseCHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

encryption

+

str

+

Yes

+

Explanation:

+

SSE-C used for encrypting objects

+

Value range:

+

AES256

+

Default value:

+

None

+

key

+

str

+

Yes

+

Explanation:

+

Key used in SSE-C encryption. It corresponds to the encryption method. For example, if encryption is set to AES256, the key is calculated using the AES-256 algorithm.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 7 SseKmsHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

encryption

+

str

+

Yes

+

Explanation:

+

SSE-KMS used for encrypting objects

+

Value range:

+

kms

+

Default value:

+

None

+

key

+

str

+

No

+

Explanation:

+

Master key used in SSE-KMS

+

Value range:

+

The following two formats are supported:

+
  • regionID:domainID:key/key_id
  • key_id
+

In the preceding formats:

+ +

Default value:

+
  • If this parameter is not specified, the default master key will be used.
  • If there is no such a default master key, OBS will create one and use it by default.
+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 8 ExtensionGrant

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

granteeId

+

str

+

No

+

Explanation:

+

Account (domain) ID of the grantee

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and IAM User ID? (SDK for Python)

+

Default value:

+

None

+

permission

+

str

+

No

+

Explanation:

+

Granted permissions

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
Table 9 Permission

Constant

+

Description

+

READ

+

Read permission

+

A grantee with this permission for a bucket can obtain the list of objects, multipart uploads, bucket metadata, and object versions in the bucket.

+

A grantee with this permission for an object can obtain the object content and metadata.

+

WRITE

+

Write permission

+

A grantee with this permission for a bucket can upload, overwrite, and delete any object or part in the bucket.

+

Such permission for an object is not applicable.

+

READ_ACP

+

Permission to read ACL configurations

+

A grantee with this permission can obtain the ACL of a bucket or object.

+

A bucket or object owner has this permission for the bucket or object permanently.

+

WRITE_ACP

+

Permission to modify ACL configurations

+

A grantee with this permission can update the ACL of a bucket or object.

+

A bucket or object owner has this permission for the bucket or object permanently.

+

A grantee with this permission can modify the access control policy and thus the grantee obtains full access permissions.

+

FULL_CONTROL

+

Full control access, including read and write permissions for a bucket and its ACL, or for an object and its ACL.

+

A grantee with this permission for a bucket has READ, WRITE, READ_ACP, and WRITE_ACP permissions for the bucket.

+

A grantee with this permission for an object has READ, READ_ACP, and WRITE_ACP permissions for the object.

+
+
+
+

Responses

+
+ + + + + + + +
Table 10 List of returned results

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 11 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + +
Table 12 GetResult.body

GetResult.body Type

+

Description

+

CopyObjectResponse

+

Explanation:

+

Response to the request for copying an object

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 13 CopyObjectResponse

Parameter

+

Type

+

Description

+

lastModified

+

str

+

Explanation:

+

Time when the last modification was made to the target object

+

Value range:

+

UTC time

+

Default value:

+

None

+

etag

+

str

+

Explanation:

+

Base64-encoded, 128-bit MD5 value of an object. ETag is the unique identifier of the object contents and is used to determine whether the contents of an object are changed. For example, if the ETag value is A when an object is uploaded and is B when the object is downloaded, this indicates the contents of the object are changed. The ETag reflects changes only to the contents of an object, not its metadata. Objects created by the upload and copy operations have unique ETags after being encrypted using MD5.

+

Restrictions:

+

If an object is encrypted using server-side encryption, the ETag is not the MD5 value of the object.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

copySourceVersionId

+

str

+

Explanation:

+

Version ID of the source object.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

versionId

+

str

+

Explanation:

+

Version ID of the target object

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

sseKms

+

str

+

Explanation:

+

SSE-KMS is used for encrypting objects on the server side.

+

Value range:

+

kms

+

Default value:

+

None

+

sseKmsKey

+

str

+

Explanation:

+

ID of the KMS master key when SSE-KMS is used

+

Value range:

+

Valid value formats are as follows:

+
  1. regionID:domainID:key/key_id
  2. key_id
+

In the preceding formats:

+ +

Default value:

+
  • If this parameter is not specified, the default master key will be used.
  • If there is no such a default master key, OBS will create one and use it by default.
+

sseC

+

str

+

Explanation:

+

Algorithm used to encrypt and decrypt objects with SSE-C

+

Value range:

+

AES256

+

Default value:

+

None

+

sseCKeyMd5

+

str

+

Explanation:

+

MD5 value of the key for encrypting objects when SSE-C is used. This value is used to check whether any error occurs during the transmission of the key.

+

Restrictions:

+

The value is encrypted by MD5 and then encoded by Base64, for example, 4XvB3tbNTN+tIEVa0/fGaQ==.

+

Default value:

+

None

+
+
+
+

Code Examples

This example copies an object from one bucket to another.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
from obs import ObsClient
+from obs import CopyObjectHeader
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    # Specify additional headers of the request for copying an object.
+    headers = CopyObjectHeader()
+    # Set directive of headers to REPLACE when custom metadata is configured.
+    headers.directive = 'REPLACE'
+    # Specify the value of if_match. If the ETag of the source object is the same as the one specified by this parameter, the source object is copied. Otherwise, an error code is returned.
+    headers.if_match = '8f4e******************ba8c'
+    # Specify custom metadata of the target object.
+    metadata = {'meta1': 'value1'}
+    # Specify a source bucket.
+    sourceBucketName = 'sourcebucket'
+    # Specify a source object.
+    sourceObjectKey = 'sourceobjectkey'
+    # Specify a target bucket.
+    destBucketName = 'destbucket'
+    # Specify a target object name.
+    destObjectKey = 'destobjectkey'
+    # Copy the object.
+    resp = obsClient.copyObject(sourceBucketName, sourceObjectKey, destBucketName, destObjectKey,
+                                metadata, headers)
+
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Copy Object Succeeded')
+        print('requestId:', resp.requestId)
+        print('etag:', resp.body.etag)
+        print('lastModified:', resp.body.lastModified)
+        print('versionId:', resp.body.versionId)
+        print('copySourceVersionId:', resp.body.copySourceVersionId)
+    else:
+        print('Copy Object Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Copy Object Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0918.html b/docs/obs_3rd_party/python_sdk/obs_22_0918.html new file mode 100644 index 000000000..36c721340 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0918.html @@ -0,0 +1,348 @@ + + +

Deleting an Object (SDK for Python)

+

Function

This API deletes an object in the specified bucket to save space and costs.

+
+

Restrictions

+
+

Method

ObsClient.deleteObject(bucketName, objectKey, versionId, extensionHeaders)
+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

str

+

Yes

+

Explanation:

+

Target object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

versionId

+

str

+

No

+

Explanation:

+

Object version ID, for example, G001117FCE89978B0000401205D5DC9

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None. If this parameter is left blank, the latest version of the object is deleted.

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + +
Table 2 List of returned results

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + +
Table 4 GetResult.body

GetResult.body Type

+

Description

+

DeleteObjectResponse

+

Explanation:

+

Response results of the request for deleting an object For details, see Table 5.

+
+
+ +
+ + + + + + + + + + + + + +
Table 5 DeleteObjectResponse

Parameter

+

Type

+

Description

+

deleteMarker

+

bool

+

Explanation:

+

Whether the deleted object is a delete marker

+

Value range:

+
  • true: The deleted object is a delete marker.
  • false: The deleted object is not a delete marker.
+

Default value:

+

false

+

versionId

+

str

+

Explanation:

+

Object version ID, for example, G001117FCE89978B0000401205D5DC9

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None. If this parameter is left blank, the latest version of the object is deleted.

+
+
+
+

Code Examples

This example deletes object objectname from bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName = "examplebucket"
+    objectKey = "objectname"
+    # Specify versionId if you want to delete an object version. If versioning is not enabled for the bucket, this value is null.
+    versionId = 'null'
+    # Delete the object.
+    resp = obsClient.deleteObject(bucketName, objectKey, versionId)
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Delete Object Succeeded')
+        print('requestId:', resp.requestId)
+        print('deleteMarker:', resp.body.deleteMarker)
+        print('versionId:', resp.body.versionId)
+    else:
+        print('Delete Object Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Delete Object Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0919.html b/docs/obs_3rd_party/python_sdk/obs_22_0919.html new file mode 100644 index 000000000..45a3bf307 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0919.html @@ -0,0 +1,514 @@ + + +

Batch Deleting Objects (SDK for Python)

+

Function

This API deletes objects in a batch from a specific bucket. Deleted objects cannot be restored.

+

OBS does not involve folders like in a file system. All elements stored in OBS buckets are objects. A folder you see on the console or other tools in OBS is essentially an object whose size is 0 and whose name ends with a slash (/). To delete a folder, you need to list all objects whose names are prefixed with the folder name and then call the batch deletion API.

+

In a batch delete operation, OBS concurrently deletes the specified objects and returns the deletion result of each object.

+
+

Restrictions

+
+

Method

ObsClient.deleteObjects(bucketName, deleteObjectsRequest, extensionHeaders)
+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

deleteObjectsRequest

+

DeleteObjectsRequest

+

Yes

+

Explanation:

+

Request parameters of deleting objects in a batch For details, see Table 2.

+

Default value:

+

None

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 2 DeleteObjectsRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

quiet

+

bool

+

No

+

Explanation:

+

Response mode to the request for deleting objects in a batch

+

Value range:

+
  • False: The detailed mode. Results of both successful and failed deletions are returned.
  • True: The quiet mode. Only results of failed deletions are returned.
+

Default value:

+

False

+

objects

+

list of Object

+

Yes

+

Explanation:

+

List of objects to be deleted. For details, see Table 3.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 3 Object

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

key

+

str

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

versionId

+

str

+

No

+

Explanation:

+

Object version ID, for example, G001117FCE89978B0000401205D5DC9

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None. If this parameter is left blank, the latest version of the object is deleted.

+
+
+
+

Responses

+
+ + + + + + + +
Table 4 List of returned results

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 5 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + +
Table 6 GetResult.body

GetResult.body Type

+

Description

+

DeleteObjectResponse

+

Explanation:

+

Response results of the request for deleting objects in a batch For details, see Table 7.

+
+
+ +
+ + + + + + + + + + + + + +
Table 7 DeleteObjectResponse

Parameter

+

Type

+

Description

+

deleteMarker

+

bool

+

Explanation:

+

Whether the deleted object is a delete marker

+

Value range:

+
  • true: The deleted object is a delete marker.
  • false: The deleted object is not a delete marker.
+

Default value:

+

false

+

versionId

+

str

+

Explanation:

+

Object version ID, for example, G001117FCE89978B0000401205D5DC9

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None. If this parameter is left blank, the latest version of the object is deleted.

+
+
+
+

Code Examples

This example deletes objects objectkey1 and objectkey2 from bucket examplebucket in a batch.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
from obs import ObsClient
+import os
+from obs import DeleteObjectsRequest
+from obs import Object
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    # Specify the objects to be deleted in a batch.
+    object1 = Object(key='objectkey1', versionId=None)
+    object2 = Object(key='objectkey2', versionId=None)
+
+# Specify encoding_type when the object name contains special characters.
+    encoding_type = 'url'
+    bucketName = "examplebucket"
+    # Batch delete the objects.
+    resp = obsClient.deleteObjects(bucketName, DeleteObjectsRequest(quiet=False, objects=[object1, object2],
+                                                                    encoding_type=encoding_type))
+
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Delete Objects Succeeded')
+        print('requestId:', resp.requestId)
+        if resp.body.deleted:
+            index = 1
+            for delete in resp.body.deleted:
+                print('delete[' + str(index) + ']')
+                print('key:', delete.key, ',deleteMarker:', delete.deleteMarker, ',deleteMarkerVersionId:',
+                      delete.deleteMarkerVersionId)
+                print('versionId:', delete.versionId)
+                index += 1
+        if resp.body.error:
+            index = 1
+            for err in resp.body.error:
+                print('err[' + str(index) + ']')
+                print('key:', err.key, ',code:', err.code, ',message:', err.message)
+                print('versionId:', err.versionId)
+                index += 1
+    else:
+        print('Delete Objects Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Delete Objects Failed')  
+    print(traceback.format_exc())
+
+
+

This example deletes all objects prefixed with test/ in bucket examplebucket.

+

In the example below, if the value of prefix is an empty string or NULL, all files in the bucket will be deleted.

+
+
from obs import ObsClient
+import os
+from obs import DeleteObjectsRequest
+from obs import Object
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName = "examplebucket"
+    # Specify the folder to be deleted.
+    prefix = 'test/'
+    # Specify the maximum number of objects to be listed at a time. 1000 is used in this example.
+    max_num = 1000
+    mark = None
+    index = 1
+    failed_list = []
+    while True:
+        resp = obsClient.listObjects(bucketName=bucketName, prefix=prefix, marker=mark, max_keys=max_num,
+                                     encoding_type='url')
+        if resp.status < 300:
+            need_to_delete_objects = [Object(key=i["key"], versionId=None) for i in resp.body["contents"]]
+            del_resp = obsClient.deleteObjects(bucketName,
+                                               DeleteObjectsRequest(False, need_to_delete_objects, encoding_type="url"))
+            for delete in del_resp.body.deleted:
+                print("Successfully deleted %s " % delete.key)
+                index += 1
+            if del_resp.body.error:
+                for err in del_resp.body.error:
+                    print("Failed to delete %s" % err.key)
+                    failed_list.append(err.key)
+            if resp.body.is_truncated is True:
+                mark = resp.body.next_marker
+            else:
+                break
+        else:
+            print('errorCode:', resp.errorCode)
+            print('errorMessage:', resp.errorMessage)
+            break
+    print("Total deleted %s objects" % index)
+    for i in failed_list:
+        print("Failed to delete %s, please try again" % i)
+except:
+    print('Delete Objects Failed') 
+    print(traceback.format_exc())
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0920.html b/docs/obs_3rd_party/python_sdk/obs_22_0920.html new file mode 100644 index 000000000..99766d24b --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0920.html @@ -0,0 +1,701 @@ + + +

Obtaining Object Metadata (SDK for Python)

+

Function

Object metadata is a set of name-value pairs that describe the object and is used for object management.

+

Currently, only the system-defined metadata can be obtained. System-defined metadata consists of system-controlled metadata and user-controlled metadata.

+

This API sends a HEAD request to obtain the metadata of an object in a specified bucket.

+
+

Restrictions

+
+

Method

ObsClient.getObjectMetadata(bucketName, objectKey, versionId, sseHeader, origin, requestHeaders, extensionHeaders)
+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

str

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

versionId

+

str

+

No

+

Explanation:

+

Object version ID, for example, G001117FCE89978B0000401205D5DC9A

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

origin

+

str

+

No

+

Explanation:

+

Origin of the cross-domain request specified by the preflight request. Generally, it is a domain name.

+

Restrictions:

+

You can configure one or more rules and use at most one wildcard character (*) in each rule. If you want to configure multiple rules, separate them using a line breaker.

+

Default value:

+

None

+

requestHeaders

+

str

+

No

+

Explanation:

+

HTTP headers in a cross-origin request Only CORS requests matching the allowed headers are valid.

+

Restrictions:

+

You can enter multiple allowed headers, with one separated from another using a line break. Each header can contain one wildcard character (*) at most. Spaces, ampersands (&), colons (:), and less-than signs (<) are not allowed.

+

Default value:

+

None

+

sseHeader

+

SseCHeader

+

No

+

Explanation:

+

Header for server-side decryption

+

Value range:

+

For details, see Table 2.

+

Default value:

+

None

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 2 SseCHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

encryption

+

str

+

Yes

+

Explanation:

+

SSE-C used for encrypting objects

+

Value range:

+

AES256

+

Default value:

+

None

+

key

+

str

+

Yes

+

Explanation:

+

Key used in SSE-C encryption. It corresponds to the encryption method. For example, if encryption is set to AES256, the key is calculated using the AES-256 algorithm.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + +
Table 3 List of returned results

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 4 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + +
Table 5 GetResult.body

GetResult.body Type

+

Description

+

GetObjectMetadataResponse

+

Explanation:

+

Response to the request for obtaining object metadata For details, see Table 6.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 6 GetObjectMetadataResponse

Parameter

+

Type

+

Description

+

storageClass

+

str

+

Explanation:

+

Object storage class.

+

Value range:

+
  • If the storage class is Standard, leave this parameter blank.
  • For details about the available storage classes, see Table 7.
+

Default value:

+

None

+

accessContorlAllowOrigin

+

str

+

Explanation:

+

If Origin in the request meets the CORS rules of the bucket, AllowedOrigin specified in the CORS rules is returned. AllowedOrigin indicates the origin from which requests can access the bucket.

+

Restrictions:

+

Domain name of the origin. Each origin can contain only one wildcard character (*), for example, https://*.vbs.example.com.

+

Default value:

+

None

+

accessContorlAllowHeaders

+

str

+

Explanation:

+

If RequestHeader in the request meets the CORS rules of the bucket, AllowedHeader specified in the CORS rules is returned. AllowedHeader indicates the allowed headers for cross-origin requests. Only CORS requests matching the allowed headers are valid.

+

Restrictions:

+

Each header can contain at most one wildcard character (*). Spaces, ampersands (&), colons (:), less-than signs (<), and full-width characters are not allowed.

+

Default value:

+

None

+

accessContorlAllowMethods

+

str

+

Explanation:

+

AllowedMethod in the CORS rules of the bucket. It specifies the HTTP method of cross-origin requests, that is, the operation type of buckets and objects.

+

Value range:

+

The following HTTP methods are supported:

+
  • GET
  • PUT
  • HEAD
  • POST
  • DELETE
+

Default value:

+

None

+

accessContorlExposeHeaders

+

str

+

Explanation:

+

ExposeHeader in the CORS rules of the bucket. It specifies the CORS-allowed additional headers in the response. These headers provide additional information to clients. By default, your browser can only access headers Content-Length and Content-Type. If your browser needs to access other headers, add them to a list of the allowed additional headers.

+

Restrictions:

+

Spaces, wildcard characters (*), ampersands (&), colons (:), and less-than signs (<) are not allowed.

+

Default value:

+

None

+

accessContorlMaxAge

+

int

+

Explanation:

+

MaxAgeSeconds in the CORS rules of the bucket. It specifies the time your client can cache the response for a cross-origin request.

+

Restrictions:

+

Each CORS rule can contain only one MaxAgeSeconds.

+

Value range:

+

An integer greater than or equal to 0, in seconds

+

Default value:

+

100

+

contentLength

+

int

+

Explanation:

+

Object size

+

Value range:

+

The value ranges from 0 TB to 48.8 TB, in bytes.

+

Default value:

+

None

+

contentType

+

str

+

Explanation:

+

MIME type of the file to be uploaded. MIME type is a standard way of describing a data type and is used by the browser to decide how to display data.

+

Value range:

+

See What Is Content-Type (MIME)? (Python SDK)

+

Default value:

+

None

+

lastModified

+

str

+

Explanation:

+

Time when the last modification was made to the object

+

Restrictions:

+

The time must be in the GMT format, for example, Wed, 25 Mar 2020 02:39:52 GMT.

+

Default value:

+

None

+

etag

+

str

+

Explanation:

+

Base64-encoded, 128-bit MD5 value of an object. ETag is the unique identifier of the object contents and is used to determine whether the contents of an object are changed. For example, if the ETag value is A when an object is uploaded and is B when the object is downloaded, this indicates the contents of the object are changed. The ETag reflects changes only to the contents of an object, not its metadata. Objects created by the upload and copy operations have unique ETags after being encrypted using MD5.

+

Restrictions:

+

If an object is encrypted using server-side encryption, the ETag is not the MD5 value of the object.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

versionId

+

str

+

Explanation:

+

Object version ID.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

restore

+

str

+

Explanation:

+

Restore status of an object. This header is returned when a Cold object is being restored or has been restored.

+

For example, ongoing-request="true" indicates that the object is being restored. ongoing-request="false", expiry-date="Wed, 7 Nov 2012 00:00:00 GMT" indicates that the object has been restored. expiry-date indicates when the restored object expires.

+

Restrictions:

+

This parameter is only available for Cold objects.

+

Default value:

+

None

+

expiration

+

str

+

Explanation:

+

Expiration details. Example: "expiry-date=\"Mon, 11 Sep 2023 00:00:00 GMT\""

+

Default value:

+

None

+

sseKms

+

str

+

Explanation:

+

SSE-KMS is used for encrypting objects on the server side.

+

Value range:

+

kms

+

Default value:

+

None

+

sseKmsKey

+

str

+

Explanation:

+

ID of the KMS master key when SSE-KMS is used

+

Value range:

+

Valid value formats are as follows:

+
  1. regionID:domainID:key/key_id
  2. key_id
+

In the preceding formats:

+ +

Default value:

+
  • If this parameter is not specified, the default master key will be used.
  • If there is no such a default master key, the system will create one and use it by default.
+

sseC

+

str

+

Explanation:

+

SSE-C algorithm

+

Value range:

+

AES256

+

Default value:

+

None

+

sseCKeyMd5

+

str

+

Explanation:

+

MD5 value of the key for encrypting objects when SSE-C is used. This value is used to check whether any error occurs during the transmission of the key.

+

Restrictions:

+

The value is encrypted by MD5 and then encoded by Base64, for example, 4XvB3tbNTN+tIEVa0/fGaQ==.

+

Default value:

+

None

+

websiteRedirectLocation

+

str

+

Explanation:

+

If the bucket is configured with website hosting, the request for obtaining the object can be redirected to another object in the bucket or an external URL. This parameter specifies the address the request for the object is redirected to.

+

The request is redirected to object anotherPage.html in the same bucket:

+

WebsiteRedirectLocation:/anotherPage.html

+

The request is redirected to an external URL http://www.example.com/:

+

WebsiteRedirectLocation:http://www.example.com/

+

OBS obtains the specified value from the header and stores it in the object metadata WebsiteRedirectLocation.

+

Restrictions:

+
  • The value must start with a slash (/), http://, or https:// and cannot exceed 2 KB.
  • OBS only supports redirection for objects in the root directory of a bucket.
+

Default value:

+

None

+

isAppendable

+

bool

+

Explanation:

+

Whether the object is appendable

+

Value range:

+

True: The object is appendable.

+

False: The object is not appendable.

+

Default value:

+

None

+

nextPosition

+

int

+

Explanation:

+

Start position for next appending

+

Value range:

+

0 to the object length, in bytes.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 7 StorageClass

Parameter

+

Type

+

Description

+

STANDARD

+

Standard storage class

+

Explanation:

+

Features low access latency and high throughput and is used for storing massive, frequently accessed (multiple times a month) or small objects (< 1 MB) requiring quick response.

+

WARM

+

Warm storage class

+

Explanation:

+

Used for storing data that is semi-frequently accessed (fewer than 12 times a year) but is instantly available when needed.

+

COLD

+

Cold storage class

+

Explanation:

+

Used for storing rarely accessed (once a year) data.

+
+
+

You can obtain custom metadata from the response headers.

+
+
+

Code Examples

This example returns the metadata of object objectname.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName = "examplebucket"
+    objectKey = "objectname"
+    # Obtain object metadata.
+    resp = obsClient.getObjectMetadata(bucketName, objectKey)
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Get Object Metadata Succeeded')
+        print('requestId:', resp.requestId)
+        print('etag:', resp.body.etag)
+        print('lastModified:', resp.body.lastModified)
+        print('contentType:', resp.body.contentType)
+        print('contentLength:', resp.body.contentLength)
+    else:
+        print('Get Object Metadata Failed')
+        print('requestId:', resp.requestId)
+        print('status:', resp.status)
+        print('reason:', resp.reason)
+except:
+    print('Get Object Metadata Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0921.html b/docs/obs_3rd_party/python_sdk/obs_22_0921.html new file mode 100644 index 000000000..132570c89 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0921.html @@ -0,0 +1,503 @@ + + +

Modifying Object Metadata (SDK for Python)

+

Function

Object metadata is a set of name-value pairs that describe the object and is used for object management.

+

Currently, only the system-defined metadata can be modified.

+

System-defined metadata consists of system-controlled metadata and user-controlled metadata. The kind of metadata like Last-Modified is controlled by the system and cannot be modified. However, the kind of metadata configured for objects such as ContentLanguage can be modified by calling APIs.

+

This API modifies, deletes, or adds metadata to objects in a bucket.

+
+

Restrictions

+
+

Method

ObsClient.setObjectMetadata(bucketName, objectKey, metadata, headers, versionId, extensionHeaders)
+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

str

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

metadata

+

dict

+

No

+

Explanation:

+

Custom metadata of the object. You can add a header starting with x-obs-meta- in the request to define metadata. The custom metadata will be returned in the response when you retrieve the object or query the object metadata.

+

Restrictions:

+
  • The custom metadata cannot exceed 8 KB. To measure the custom metadata, sum the number of bytes in the UTF-8 encoding of each key and value.
  • The custom metadata keys are case insensitive, but are stored in lowercase in OBS. The key values are case sensitive.
  • Both custom metadata keys and their values must conform to US-ASCII standards. If non-ASCII or unrecognizable characters are required, they must be encoded and decoded in URL or Base64 on the client, because the server does not perform such operations.
+

Default value:

+

None

+

headers

+

SetObjectMetadataHeader

+

No

+

Explanation:

+

Request headers for configuring object metadata. For details, see Table 2.

+

versionId

+

str

+

No

+

Explanation:

+

Object version ID, for example, G001117FCE89978B0000401205D5DC9A

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 SetObjectMetadataHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

removeUnset

+

bool

+

No

+

Explanation:

+

Used to set the metadata operation indicator

+

Value range:

+

True: The metadata operation indicator is REPLACE. REPLACE uses the complete header carried in the current request to replace the original one and deletes the metadata that is not specified.

+

False: The metadata operation indicator is REPLACE_NEW. REPLACE_NEW replaces the metadata that already has a value, assigns a value to the metadata that does not have a value, and retains the metadata that is not specified.

+

Default value:

+

False

+

location

+

str

+

No

+

Explanation:

+

If the bucket is configured with website hosting, the request for obtaining the object can be redirected to another object in the bucket or an external URL.

+

The request is redirected to object anotherPage.html in the same bucket:

+

WebsiteRedirectLocation:/anotherPage.html

+

The request is redirected to an external URL http://www.example.com/:

+

WebsiteRedirectLocation:http://www.example.com/

+

OBS obtains the specified value from the header and stores it in the object metadata WebsiteRedirectLocation.

+

Restrictions:

+
  • The value must start with a slash (/), http://, or https:// and cannot exceed 2 KB.
  • OBS only supports redirection for objects in the root directory of a bucket.
+

Default value:

+

None

+

cacheControl

+

str

+

No

+

Explanation:

+

Cache-Control header in the response. It specifies the cache behavior of the web page when an object is downloaded.

+

Default value:

+

None

+

contentDisposition

+

str

+

No

+

Explanation:

+

Content-Disposition header in the response It specifies the name of an object when it is downloaded.

+

Default value:

+

None

+

contentEncoding

+

str

+

No

+

Explanation:

+

Content-Encoding header in the response It specifies the content encoding format when an object is downloaded.

+

Default value:

+

None

+

contentLanguage

+

str

+

No

+

Explanation:

+

Content-Language header in the response It specifies the content language format when an object is downloaded.

+

Default value:

+

None

+

contentType

+

str

+

No

+

Explanation:

+

Content-Type header in the response. It specifies the file type of an object when it is downloaded.

+

Default value:

+

None

+

expires

+

str

+

No

+

Explanation:

+

Expires header in the response. It specifies the cache expiration time of the web page when the object is downloaded.

+
CAUTION:

This parameter cannot be used to configure the expiration time of an object. To configure the object expiration time, see Setting an Object Expiration Time (SDK for Python).

+
+

Default value:

+

None

+

storageClass

+

str

+

No

+

Explanation:

+

Storage classes

+

Value range:

+

See Table 3.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 3 StorageClass

Parameter

+

Type

+

Description

+

STANDARD

+

Standard storage class

+

Explanation:

+

Features low access latency and high throughput and is used for storing massive, frequently accessed (multiple times a month) or small objects (< 1 MB) requiring quick response.

+

WARM

+

Warm storage class

+

Explanation:

+

Used for storing data that is semi-frequently accessed (fewer than 12 times a year) but is instantly available when needed.

+

COLD

+

Cold storage class

+

Explanation:

+

Used for storing rarely accessed (once a year) data.

+
+
+
+

Responses

+
+ + + + + + + +
Table 4 List of returned results

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 5 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+
+

Code Examples

This example configures the object metadata.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
from obs import SetObjectMetadataHeader
+from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    # Specify custom metadata.
+    metadata = {'property1': 'property-value1', 'property2': 'property-value2'}
+    # Specify the additional headers of the request for configuring object metadata.
+    headers = SetObjectMetadataHeader()
+    # (Optional) Specify the MIME type of the object.
+    headers.contentType = "Your Content-Type"
+    bucketName = "examplebucket"
+    objectKey = "objectname"
+    # Configure metadata for the object.
+    resp = obsClient.setObjectMetadata(bucketName, objectKey, metadata, headers)
+
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Set Object Metadata Succeeded')
+        print('requestId:', resp.requestId)
+    else:
+        print('Set Object Metadata Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Set Object Metadata Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0922.html b/docs/obs_3rd_party/python_sdk/obs_22_0922.html new file mode 100644 index 000000000..461b1b83b --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0922.html @@ -0,0 +1,769 @@ + + +

Configuring an Object ACL (SDK for Python)

+

Function

OBS allows the control of access permissions for objects. By default, only object creators have the read and write permissions on the object. However, the creator can set a public access policy to assign the read permission to all other users. If an object is encrypted with SSE-KMS, the ACL configured for it is not in effect in the cross-tenant case.

+

You can set an access control policy when uploading an object or call an ACL API to modify or obtain the ACL of an existing object.

+

This API sets an ACL for an object in a specified bucket.

+
+

Restrictions

+
+

Method

ObsClient.setObjectAcl(bucketName, objectKey, acl, versionId, aclControl, extensionHeaders)
+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

str

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

acl

+

ACL

+

No

+

Explanation:

+

Access permissions on the object

+

Value range:

+

See Table 2.

+

Default value:

+

None

+

versionId

+

str

+

No

+

Explanation:

+

Object version ID, for example, G001117FCE89978B0000401205D5DC9A

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

aclControl

+

HeadPermission

+

No

+

Explanation:

+

Pre-defined ACL For details, see Table 3.

+

Default value:

+

None

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+

acl and aclControl are mutually exclusive.

+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 2 ACL

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

owner

+

Owner

+

Yes if used as a request parameter

+

Explanation:

+

Bucket owner For details, see Table 4.

+

Restrictions:

+

Owner and Grants must be used together and they cannot be used with aclControl.

+

Default value:

+

None

+

grants

+

list of Grant

+

Yes if used as a request parameter

+

Explanation:

+

List of grantees' permission information. For details, see Table 5.

+

Restrictions:

+

Owner and Grants must be used together and they cannot be used with aclControl.

+

Default value:

+

None

+

delivered

+

bool

+

No if used as a request parameter

+

Explanation:

+

Whether the bucket ACL is applied to objects in the bucket. This parameter is valid only when you configure the object ACL.

+

Value range:

+

True: The bucket ACL is applied to objects in the bucket.

+

False: The bucket ACL is not applied to objects in the bucket.

+

Default value:

+

False

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 HeadPermission

Constant

+

Default Value

+

Description

+

HeadPermission.PRIVATE

+

private

+

Private read/write

+

A bucket or object can only be accessed by its owner.

+

HeadPermission.PUBLIC_READ

+

public-read

+

Public read and private write

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, metadata, and object versions in the bucket.

+

If it is granted on an object, anyone can read the content and metadata of the object.

+

HeadPermission.PUBLIC_READ_WRITE

+

public-read-write

+

Public read/write

+

If this permission is granted on a bucket, anyone can read the object list, multipart tasks, metadata, and object versions in the bucket, and can upload or delete objects, initiate multipart upload tasks, upload parts, assemble parts, copy parts, and abort multipart upload tasks.

+

If it is granted on an object, anyone can read the content and metadata of the object.

+

HeadPermission.PUBLIC_READ_DELIVERED

+

public-read-delivered

+

Public read on a bucket as well as objects in the bucket

+

If this permission is granted on a bucket, anyone can read the object list, multipart tasks, metadata, and object versions, and read the content and metadata of objects in the bucket.

+
NOTE:

PUBLIC_READ_DELIVERED cannot be applied to objects.

+
+

HeadPermission.PUBLIC_READ_WRITE_DELIVERED

+

public-read-write-delivered

+

Public read/write on a bucket as well as objects in the bucket

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, metadata, and object versions in the bucket, and can upload or delete objects, initiate multipart upload tasks, upload parts, assemble parts, copy parts, and abort multipart uploads. They can also read the content and metadata of objects in the bucket.

+
NOTE:

PUBLIC_READ_WRITE_DELIVERED cannot be applied to objects.

+
+

HeadPermission.BUCKET_OWNER_FULL_CONTROL

+

public-read-write-delivered

+

If this permission is granted on an object, only the bucket and object owners have the full control over the object. By default, if you upload an object to a bucket of any other user, the bucket owner does not have the permissions on your object. After you grant this policy to the bucket owner, the bucket owner can have full control over your object.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 4 Owner

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

owner_id

+

str

+

Yes if used as a request parameter

+

Explanation:

+

Account (domain) ID of the owner

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and IAM User ID? (SDK for Python)

+

Default value:

+

None

+

owner_name

+

str

+

No if used as a request parameter

+

Explanation:

+

Account name of the owner

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and IAM User ID? (SDK for Python)

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 5 Grant

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantee

+

Grantee

+

Yes if used as a request parameter

+

Explanation:

+

Grantee

+

Value range:

+

See Table 7.

+

Default value:

+

None

+

permission

+

str

+

Yes if used as a request parameter

+

Explanation:

+

Granted permission

+

Value range:

+

See Table 6.

+

Default value:

+

None

+

delivered

+

bool

+

No if used as a request parameter

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket

+

Value range:

+

True: The bucket ACL is applied to all objects in the bucket.

+

False: The bucket ACL is not applied to all objects in the bucket.

+

Default value:

+

False

+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
Table 6 Permission

Constant

+

Description

+

READ

+

Read permission

+

A grantee with this permission for a bucket can obtain the list of objects, multipart uploads, bucket metadata, and object versions in the bucket.

+

A grantee with this permission for an object can obtain the object content and metadata.

+

WRITE

+

Write permission

+

A grantee with this permission for a bucket can upload, overwrite, and delete any object or part in the bucket.

+

Such permission for an object is not applicable.

+

READ_ACP

+

Permission to read ACL configurations

+

A grantee with this permission can obtain the ACL of a bucket or object.

+

A bucket or object owner has this permission for the bucket or object permanently.

+

WRITE_ACP

+

Permission to modify ACL configurations

+

A grantee with this permission can update the ACL of a bucket or object.

+

A bucket or object owner has this permission for the bucket or object permanently.

+

A grantee with this permission can modify the access control policy and thus the grantee obtains full access permissions.

+

FULL_CONTROL

+

Full control access, including read and write permissions for a bucket and its ACL, or for an object and its ACL.

+

A grantee with this permission for a bucket has READ, WRITE, READ_ACP, and WRITE_ACP permissions for the bucket.

+

A grantee with this permission for an object has READ, READ_ACP, and WRITE_ACP permissions for the object.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 7 Grantee

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantee_id

+

str

+

Yes if the parameter is used as a request parameter and group is left blank

+

Explanation:

+

Account (domain) ID of the grantee

+

Value range:

+

+

Default value:

+

None

+

grantee_name

+

str

+

No if used as a request parameter

+

Explanation:

+

Account name of the grantee

+

Restrictions:

+
  • Cannot contain full-width characters.
  • Starts with a letter.
  • Contains 6 to 32 characters.
  • Contains only letters, digits, hyphens (-), and underscores (_).
+

Default value:

+

None

+

group

+

str

+

Yes if the parameter is used as a request parameter and grantee_id is left blank

+

Explanation:

+

Authorized user group

+

Value range:

+

See Table 8.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + +
Table 8 Group

Constant

+

Description

+

ALL_USERS

+

All users

+

AUTHENTICATED_USERS

+

Authorized users. This constant is deprecated.

+

LOG_DELIVERY

+

Log delivery group. This constant is deprecated.

+
+
+
+

Responses

+
+ + + + + + + +
Table 9 List of returned results

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 10 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+
+

Setting an Object ACL by Specifying acl

This example sets the ACL for object objectname to read and write for an IAM user (userid).

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
from obs import ObsClient
+import os
+from obs import ACL
+from obs import Owner
+from obs import Grant, Permission
+from obs import Grantee
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    # Specify the account ID of the bucket owner (ownerid as an example).
+    owner = Owner(owner_id='ownerid')
+    # Grant the read and write permissions to an IAM user (userid).
+    grantee = Grantee(grantee_id='userid')
+    grant0 = Grant(grantee=grantee, permission=Permission.READ)
+    grant0 = Grant(grantee=grantee, permission=Permission.WRITE)
+    # Set the ACL.
+    acl = ACL(owner=owner, grants=[grant0])
+    bucketName = "examplebucket"
+    objectKey = "objectname"
+    # Configure the object ACL by specifying acl.
+    resp = obsClient.setObjectAcl(bucketName, objectKey, acl)
+
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Set Object Acl Succeeded')
+        print('requestId:', resp.requestId)
+    else:
+        print('Set Object Acl Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Set Object Acl Failed')
+    print(traceback.format_exc())
+
+
+
+

Setting an Object ACL by Specifying aclControl

This example sets a pre-defined object ACL to private read and write.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
from obs import ObsClient
+import os
+from obs import HeadPermission
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    # Set the pre-defined ACL to PRIVATE to ensure high security.
+    aclControl = HeadPermission.PRIVATE
+    bucketName = "examplebucket"
+    objectKey = "objectname"
+    # Configure the object ACL by specifying acl.
+    resp = obsClient.setObjectAcl(bucketName, objectKey, aclControl=aclControl)
+
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Set Object Acl Succeeded')
+        print('requestId:', resp.requestId)
+    else:
+        print('Set Object Acl Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Set Object Acl Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0923.html b/docs/obs_3rd_party/python_sdk/obs_22_0923.html new file mode 100644 index 000000000..5b77434a6 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0923.html @@ -0,0 +1,609 @@ + + +

Obtaining an Object ACL (SDK for Python)

+

Function

This API returns the ACL of an object in a specified bucket.

+
+

Restrictions

+
+

Method

ObsClient.getObjectAcl(bucketName, objectKey, versionId, extensionHeaders)
+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

str

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

versionId

+

str

+

No

+

Explanation:

+

Object version ID, for example, G001117FCE89978B0000401205D5DC9A

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + +
Table 2 List of returned results

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + +
Table 4 GetResult.body

GetResult.body Type

+

Description

+

ACL

+

Explanation:

+

Access permissions on the object. For details, see Table 5.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 5 ACL

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

owner

+

Owner

+

Yes if used as a request parameter

+

Explanation:

+

Bucket owner. For details, see Table 6.

+

Restrictions:

+

owner and grants must be used together and they cannot be used with ACL.

+

Default value:

+

None

+

grants

+

list of Grant

+

Yes if used as a request parameter

+

Explanation:

+

List of grantees' permission information. For details, see Table 7.

+

Default value:

+

None

+

delivered

+

bool

+

No if used as a request parameter

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket

+

Value range:

+

True: The bucket ACL is applied to all objects in the bucket.

+

False: The bucket ACL is not applied to all objects in the bucket.

+

Default value:

+

False

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 6 Owner

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

owner_id

+

str

+

Yes if used as a request parameter

+

Explanation:

+

Account (domain) ID of the owner

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and IAM User ID? (SDK for Python)

+

Default value:

+

None

+

owner_name

+

str

+

No if used as a request parameter

+

Explanation:

+

Account name of the owner

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and IAM User ID? (SDK for Python)

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 7 Grant

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantee

+

Grantee

+

Yes if used as a request parameter

+

Explanation:

+

Grantee information. For details, see Table 9.

+

Default value:

+

None

+

permission

+

str

+

Yes if used as a request parameter

+

Explanation:

+

Granted permission

+

Value range:

+

See Table 8.

+

Default value:

+

None

+

delivered

+

bool

+

No if used as a request parameter

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket

+

Value range:

+

True: The bucket ACL is applied to all objects in the bucket.

+

False: The bucket ACL is not applied to all objects in the bucket.

+

Default value:

+

False

+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
Table 8 Permission

Constant

+

Description

+

READ

+

Read permission

+

A grantee with this permission for a bucket can obtain the list of objects, multipart uploads, bucket metadata, and object versions in the bucket.

+

A grantee with this permission for an object can obtain the object content and metadata.

+

WRITE

+

Write permission

+

A grantee with this permission for a bucket can upload, overwrite, and delete any object or part in the bucket.

+

Such permission for an object is not applicable.

+

READ_ACP

+

Permission to read ACL configurations

+

A grantee with this permission can obtain the ACL of a bucket or object.

+

A bucket or object owner has this permission for the bucket or object permanently.

+

WRITE_ACP

+

Permission to modify ACL configurations

+

A grantee with this permission can update the ACL of a bucket or object.

+

A bucket or object owner has this permission for the bucket or object permanently.

+

A grantee with this permission can modify the access control policy and thus the grantee obtains full access permissions.

+

FULL_CONTROL

+

Full control access, including read and write permissions for a bucket and its ACL, or for an object and its ACL.

+

A grantee with this permission for a bucket has READ, WRITE, READ_ACP, and WRITE_ACP permissions for the bucket.

+

A grantee with this permission for an object has READ, READ_ACP, and WRITE_ACP permissions for the object.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 9 Grantee

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantee_id

+

str

+

Yes if the parameter is used as a request parameter and group is left blank

+

Explanation:

+

Account (domain) ID of the grantee

+

Value range:

+

+

Default value:

+

None

+

grantee_name

+

str

+

No if used as a request parameter

+

Explanation:

+

Account name of the grantee

+

Restrictions:

+
  • Cannot contain full-width characters.
  • Starts with a letter.
  • Contains 6 to 32 characters.
  • Contains only letters, digits, hyphens (-), and underscores (_).
+

Default value:

+

None

+

group

+

str

+

Yes if the parameter is used as a request parameter and grantee_id is left blank

+

Explanation:

+

Authorized user group

+

Value range:

+

See Table 10.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + +
Table 10 Group

Constant

+

Description

+

ALL_USERS

+

All users

+

AUTHENTICATED_USERS

+

Authorized users. This constant is deprecated.

+

LOG_DELIVERY

+

Log delivery group. This constant is deprecated.

+
+
+
+

Code Examples

This example returns the object ACL information of object objectname.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName = "examplebucket"
+    objectKey = "objectname"
+    # Obtain the object ACL.
+    resp = obsClient.getObjectAcl(bucketName, objectKey)
+
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Get Object Acl Succeeded')
+        print('requestId:', resp.requestId)
+        print('owner_id:', resp.body.owner.owner_id)
+        print('owner_name:', resp.body.owner.owner_name)
+
+        index = 1
+        for grant in resp.body.grants:
+            print('grant [' + str(index) + ']')
+            print('grantee_id:', grant.grantee.grantee_id)
+            print('grantee_name:', grant.grantee.grantee_name)
+            print('group:', grant.grantee.group)
+            print('permission:', grant.permission)
+            index += 1
+    else:
+        print('Get Object Acl Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Get Object Acl Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_0924.html b/docs/obs_3rd_party/python_sdk/obs_22_0924.html new file mode 100644 index 000000000..b0636f158 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_0924.html @@ -0,0 +1,347 @@ + + +

Restoring a Cold Object (SDK for Python)

+

Function

To obtain the contents of an object in the Cold storage class, you need to restore the object first and then you can download it. After an object is restored, a copy of the object is saved in the Standard storage class. By doing so, the object in the Cold storage class and its copy in the Standard storage class co-exist in the bucket. The copy will be automatically deleted once its retention period expires.

+

This API is used to restore Cold objects in a specified bucket.

+
+

Restrictions

+
+

Method

ObsClient.restoreObject(bucketName, objectKey, days, tier, versionId, extensionHeaders)
+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

str

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

days

+

int

+

Yes

+

Explanation:

+

After an object is restored, a Standard copy of it is generated. This parameter specifies how long the Standard copy can be retained, that is, the validity period of the restored object.

+

Value range:

+

The value ranges from 1 to 30, in days.

+

Default value:

+

None

+

tier

+

str

+

No

+

Explanation:

+

Retrieval speed tiers. You can select a suitable tier based on your requirements for retrieval speed.

+

Value range:

+

See Table 2.

+

Default value:

+

Standard

+

versionId

+

str

+

No

+

Explanation:

+

Version ID of the Cold object to be restored

+

Default value:

+

None. If this parameter is left blank, the latest version of the object is specified.

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + +
Table 2 RestoreTier

Constant

+

Description

+

Expedited

+

Objects can be restored at an expedited speed within 1 to 5 minutes.

+

Standard

+

Objects can be restored at a standard speed within 3 to 5 hours.

+
+
+
+

Responses

+
+ + + + + + + +
Table 3 List of returned results

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+

If GetResult.status is 202, the object is being restored. If GetResult.status is 200, the object has been restored.

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 4 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+
+

Code Examples

This example restores the Cold object objectname.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName = "examplebucket"
+    objectKey = "objectname"
+    # Specify how long the restored object will be retained, in days. The value ranges from 1 to 30.
+    days = 1
+    # Specify the restoration speed. Options: Expedited or Standard
+    tier = "Expedited"
+    # Restore the Cold object.
+    resp = obsClient.restoreObject(bucketName, objectKey, days, tier)
+
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Restore Object Succeeded')
+        print('requestId:', resp.requestId)
+    else:
+        print('Restore Object Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Restore Object Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_1000.html b/docs/obs_3rd_party/python_sdk/obs_22_1000.html new file mode 100644 index 000000000..834089fa2 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_1000.html @@ -0,0 +1,25 @@ + + +

APIs Related to Multipart Upload (SDK for Python)

+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_1001.html b/docs/obs_3rd_party/python_sdk/obs_22_1001.html new file mode 100644 index 000000000..b911a98cb --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_1001.html @@ -0,0 +1,157 @@ + + +

Multipart Upload Overview (SDK for Python)

+

You can upload large files using multipart upload. Multipart upload is applicable to many scenarios, including:

+ +

+

A multipart upload consists of the following steps:

+
  1. Initiate a multipart upload (ObsClient.initiateMultipartUpload).
  2. Upload parts one by one or concurrently (ObsClient.uploadPart).
  3. Assemble parts (ObsClient.completeMultipartUpload) or abort the multipart upload (ObsClient.abortMultipartUpload).
+

+

This example shows a complete multipart upload, including initiating a multipart upload, uploading parts, and assembling parts.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
# -*- coding:utf-8 -*-
+from obs import ObsClient,CompleteMultipartUploadRequest, CompletePart
+import os
+import traceback
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    #Bucket name
+    bucketName = "examplebucket"
+    #Object name
+    objectKey = "objectname"
+    # Specify the MIME type for the object.
+    contentType = 'text/plain'
+    # Initiate a multipart upload.
+    resp = obsClient.initiateMultipartUpload(bucketName, objectKey,
+                                             contentType=contentType)
+    #Obtain the uploadId.
+    uploadId = resp.body["uploadId"]
+    #Specify the size of the part to upload.
+    partSize = 512 * 1024 * 1024
+    #Specify the part number.
+    partNum = 1
+    # Specify whether object indicates the file path. True is used here. The default value is False.
+    isFile = True
+    #Specify the local object file to upload.
+    filepath = r"D:\tmp\file.txt"
+    contentLength = os.path.getsize(filepath)
+    #Start offset of a part in the source file.
+    offset = 0
+    etags = {}
+
+    while offset < contentLength:
+        partSize = min(partSize, (contentLength - offset));
+        # Upload parts.
+        resp1 = obsClient.uploadPart(bucketName, objectKey, partNum, uploadId, filepath, isFile, partSize, offset)
+        etags[partNum] = resp1.body.etag
+        offset = offset + partSize
+        partNum = partNum + 1
+
+    completes = []
+    for i in range(1, partNum):
+        completes.append(CompletePart(i, etags[i]))
+    # Assemble parts.
+    completeMultipartUploadRequest = CompleteMultipartUploadRequest(parts = completes)
+    resp = obsClient.completeMultipartUpload(bucketName, objectKey, uploadId, completeMultipartUploadRequest)
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Upload Part Succeeded')
+        print('requestId:', resp.requestId)
+        print('etag:', resp.body.etag)
+    else:
+        print('Upload Part Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('multPartsUpload Failed')
+    print(traceback.format_exc())
+
+
+

+

Below lists other multipart upload operations:

+ +
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_1002.html b/docs/obs_3rd_party/python_sdk/obs_22_1002.html new file mode 100644 index 000000000..b5dd54f30 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_1002.html @@ -0,0 +1,809 @@ + + +

Initiating a Multipart Upload (SDK for Python)

+

Function

This API initiates a multipart upload and returns a globally unique upload ID. You can use the returned upload ID when you later upload, assemble, or list parts. A single object can be involved in multiple multipart uploads. Each multipart upload initiation request can contain additional headers such as acl, metadata, contentType, and encoding_type. These headers are recorded in the multipart upload metadata.

+
+

Restrictions

+
+

Method

ObsClient.initiateMultipartUpload(bucketName, objectKey, acl, storageClass, metadata, websiteRedirectLocation, contentType, sseHeader, expires, extensionGrants, extensionHeaders)
+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

str

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

acl

+

str

+

No

+

Explanation:

+

Access control list (ACL) that can be pre-defined when a bucket is created.

+

Value range:

+

See Table 2.

+

Default value:

+

PRIVATE

+

storageClass

+

str

+

No

+

Explanation:

+

Object storage class. If this parameter is not set, the object inherits the storage class of its bucket.

+

Value range:

+

See Table 3.

+

Default value:

+

STANDARD

+

metadata

+

dict

+

No

+

Explanation:

+

Custom metadata of the object to be uploaded. You can add a header starting with x-obs-meta- in the request to define metadata. The custom metadata will be returned in the response when you retrieve the object or query the object metadata.

+

Restrictions:

+
  • The custom metadata cannot exceed 8 KB. To measure the custom metadata, sum the number of bytes in the UTF-8 encoding of each key and value.
  • The custom metadata keys are case insensitive, but are stored in lowercase in OBS. The key values are case sensitive.
  • Both custom metadata keys and their values must conform to US-ASCII standards. If non-ASCII or unrecognizable characters are required, they must be encoded and decoded in URL or Base64 on the client, because the server does not perform such operations.
+

Default value:

+

None

+

websiteRedirectLocation

+

str

+

No

+

Explanation:

+

If the bucket is configured with website hosting, the request for obtaining the object can be redirected to another object in the bucket or an external URL.

+

The request is redirected to object anotherPage.html in the same bucket:

+

WebsiteRedirectLocation:/anotherPage.html

+

The request is redirected to an external URL http://www.example.com/:

+

WebsiteRedirectLocation:http://www.example.com/

+

OBS obtains the specified value from the header and stores it in the object metadata WebsiteRedirectLocation.

+

Restrictions:

+
  • The value must start with a slash (/), http://, or https:// and cannot exceed 2 KB.
  • OBS only supports redirection for objects in the root directory of a bucket.
+

Default value:

+

None

+

contentType

+

str

+

No

+

Explanation:

+

MIME type of the file to be uploaded. MIME type is a standard way of describing a data type and is used by the browser to decide how to display data.

+

Value range:

+

See What Is Content-Type (MIME)? (Python SDK)

+

Default value:

+

If you do not specify this parameter when uploading an object, the SDK determines the object type based on the suffix of the specified object name and automatically assigns a value to this parameter.

+

sseHeader

+

SseCHeader or SseKmsHeader

+

No

+

Explanation:

+

Server-side encryption header. If SSE-C is used, see Table 4. If SSE-KMS is used, see Table 5.

+

Default value:

+

None

+

expires

+

int

+

No

+

Explanation:

+

Expiration time of the object (calculated from the latest modification time of the object). Expired objects are automatically deleted.

+

Restrictions:

+

This parameter can be configured only when uploading the object. It cannot be modified by calling a metadata modification API.

+

Value range:

+

An integer greater than or equal to 0, in days

+

Default value:

+

None

+

extensionGrants

+

list of ExtensionGrant

+

No

+

Explanation:

+

List of the extended permissions for the object. For details, see Table 6.

+

Default value:

+

None

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 HeadPermission

Constant

+

Default Value

+

Description

+

HeadPermission.PRIVATE

+

private

+

Private read/write

+

A bucket or object can only be accessed by its owner.

+

HeadPermission.PUBLIC_READ

+

public-read

+

Public read and private write

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, metadata, and object versions in the bucket.

+

If it is granted on an object, anyone can read the content and metadata of the object.

+

HeadPermission.PUBLIC_READ_WRITE

+

public-read-write

+

Public read/write

+

If this permission is granted on a bucket, anyone can read the object list, multipart tasks, metadata, and object versions in the bucket, and can upload or delete objects, initiate multipart upload tasks, upload parts, assemble parts, copy parts, and abort multipart upload tasks.

+

If it is granted on an object, anyone can read the content and metadata of the object.

+

HeadPermission.PUBLIC_READ_DELIVERED

+

public-read-delivered

+

Public read on a bucket as well as objects in the bucket

+

If this permission is granted on a bucket, anyone can read the object list, multipart tasks, metadata, and object versions, and read the content and metadata of objects in the bucket.

+
NOTE:

PUBLIC_READ_DELIVERED cannot be applied to objects.

+
+

HeadPermission.PUBLIC_READ_WRITE_DELIVERED

+

public-read-write-delivered

+

Public read/write on a bucket as well as objects in the bucket

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, metadata, and object versions in the bucket, and can upload or delete objects, initiate multipart upload tasks, upload parts, assemble parts, copy parts, and abort multipart uploads. They can also read the content and metadata of objects in the bucket.

+
NOTE:

PUBLIC_READ_WRITE_DELIVERED cannot be applied to objects.

+
+

HeadPermission.BUCKET_OWNER_FULL_CONTROL

+

public-read-write-delivered

+

If this permission is granted on an object, only the bucket and object owners have the full control over the object. By default, if you upload an object to a bucket of any other user, the bucket owner does not have the permissions on your object. After you grant this policy to the bucket owner, the bucket owner can have full control over your object.

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 3 StorageClass

Parameter

+

Type

+

Description

+

STANDARD

+

Standard storage class

+

Explanation:

+

Features low access latency and high throughput and is used for storing massive, frequently accessed (multiple times a month) or small objects (< 1 MB) requiring quick response.

+

WARM

+

Warm storage class

+

Explanation:

+

Used for storing data that is semi-frequently accessed (fewer than 12 times a year) but is instantly available when needed.

+

COLD

+

Cold storage class

+

Explanation:

+

Used for storing rarely accessed (once a year) data.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 4 SseCHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

encryption

+

str

+

Yes

+

Explanation:

+

SSE-C used for encrypting objects

+

Value range:

+

AES256

+

Default value:

+

None

+

key

+

str

+

Yes

+

Explanation:

+

Key used in SSE-C encryption. It corresponds to the encryption method. For example, if encryption is set to AES256, the key is calculated using the AES-256 algorithm.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 5 SseKmsHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

encryption

+

str

+

Yes

+

Explanation:

+

SSE-KMS used for encrypting objects

+

Value range:

+

kms

+

Default value:

+

None

+

key

+

str

+

No

+

Explanation:

+

Master key used in SSE-KMS

+

Value range:

+

The following two formats are supported:

+
  • regionID:domainID:key/key_id
  • key_id
+

In the preceding formats:

+ +

Default value:

+
  • If this parameter is not specified, the default master key will be used.
  • If there is no such a default master key, OBS will create one and use it by default.
+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 6 ExtensionGrant

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

granteeId

+

str

+

No

+

Explanation:

+

Account (domain) ID of the grantee

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and IAM User ID? (SDK for Python)

+

Default value:

+

None

+

permission

+

str

+

No

+

Explanation:

+

Granted permissions. For details, see Table 7.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
Table 7 Permission

Constant

+

Description

+

READ

+

Read permission

+

A grantee with this permission for a bucket can obtain the list of objects, multipart uploads, bucket metadata, and object versions in the bucket.

+

A grantee with this permission for an object can obtain the object content and metadata.

+

WRITE

+

Write permission

+

A grantee with this permission for a bucket can upload, overwrite, and delete any object or part in the bucket.

+

Such permission for an object is not applicable.

+

READ_ACP

+

Permission to read ACL configurations

+

A grantee with this permission can obtain the ACL of a bucket or object.

+

A bucket or object owner has this permission for the bucket or object permanently.

+

WRITE_ACP

+

Permission to modify ACL configurations

+

A grantee with this permission can update the ACL of a bucket or object.

+

A bucket or object owner has this permission for the bucket or object permanently.

+

A grantee with this permission can modify the access control policy and thus the grantee obtains full access permissions.

+

FULL_CONTROL

+

Full control access, including read and write permissions for a bucket and its ACL, or for an object and its ACL.

+

A grantee with this permission for a bucket has READ, WRITE, READ_ACP, and WRITE_ACP permissions for the bucket.

+

A grantee with this permission for an object has READ, READ_ACP, and WRITE_ACP permissions for the object.

+
+
+
+

Responses

+
+ + + + + + + +
Table 8 List of returned results

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 9 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+
+ +
+ + + + + + + +
Table 10 GetResult.body

GetResult.body Type

+

Description

+

InitiateMultipartUploadResponse

+

Explanation:

+

Response to the request for initiating a multipart upload. For details, see Table 11.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 11 InitiateMultipartUploadResponse

Parameter

+

Type

+

Description

+

bucketName

+

str

+

Explanation:

+

Name of the bucket involved in the multipart upload

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

str

+

Explanation:

+

Name of the object to be uploaded. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

uploadId

+

str

+

Explanation:

+

Multipart upload ID, for example, 000001648453845DBB78F2340DD460D8

+

Value range:

+

The value must contain 1 to 32 characters.

+

Default value:

+

None

+

sseKms

+

str

+

Explanation:

+

SSE-KMS is used for encrypting objects on the server side.

+

Value range:

+

kms

+

Default value:

+

None

+

sseKmsKey

+

str

+

Explanation:

+

ID of the KMS master key when SSE-KMS is used

+

Value range:

+

Valid value formats are as follows:

+
  1. regionID:domainID:key/key_id
  2. key_id
+

In the preceding formats:

+ +

Default value:

+
  • If this parameter is not specified, the default master key will be used.
  • If there is no such a default master key, OBS will create one and use it by default.
+

sseC

+

str

+

Explanation:

+

Algorithm used to encrypt and decrypt objects with SSE-C

+

Value range:

+

AES256

+

Default value:

+

None

+

sseCKeyMd5

+

str

+

Explanation:

+

MD5 value of the key for encrypting objects when SSE-C is used. This value is used to check whether any error occurs during the transmission of the key.

+

Restrictions:

+

The value is encrypted by MD5 and then encoded by Base64, for example, 4XvB3tbNTN+tIEVa0/fGaQ==.

+

Default value:

+

None

+
+
+

Code Examples

This example initiates a multipart upload for bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName = "examplebucket"
+    objectKey = "objectname"
+    # Specify a pre-defined ACL (PRIVATE as an example).
+    acl = 'PRIVATE'
+    # Specify a storage class (STANDARD as an example) for the object.
+    storageClass = 'STANDARD'
+    # Specify a custom metadata of the object.
+    metadata = {'key': 'value'}
+    # Specify the MIME type for the object.
+    contentType = 'text/plain'
+    # Specify the lifecycle (7 as an example) for the object, in days.
+    expires = 7
+    # Initiate a multipart upload.
+    resp = obsClient.initiateMultipartUpload(bucketName, objectKey, acl, storageClass, metadata,
+                                             contentType=contentType, expires=expires, encoding_type='url')
+
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Initiate Multipart Upload Succeeded')
+        print('requestId:', resp.requestId)
+        print('bucketName:', resp.body.bucketName)
+        print('objectKey:', resp.body.objectKey)
+        print('uploadId:', resp.body.uploadId)
+    else:
+        print('Initiate Multipart Upload Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Initiate Multipart Upload Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_1003.html b/docs/obs_3rd_party/python_sdk/obs_22_1003.html new file mode 100644 index 000000000..c1137a264 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_1003.html @@ -0,0 +1,609 @@ + + +

Uploading a Part (SDK for Python)

+

Function

After a multipart upload is initiated, this API uploads a part to a specified bucket. In the upload request, the multipart upload ID must be included. Except for the part lastly being uploaded whose size ranges from 0 to 5 GB, sizes of the other parts range from 100 KB to 5 GB. Part numbers can be any number from 1 to 10,000.

+

When uploading a part, you must specify its upload ID and part number. A part number uniquely identifies a part and its position in the object you are uploading. If you upload a new part with the same part number as that of a previous part, the previously uploaded part will be overwritten. Whenever you upload a part, OBS returns the ETag header in the response. For each part upload task, you must record the part number and ETag value. These values are required in subsequent requests for you to complete a multipart upload.

+
+

Restrictions

+
+

Method

ObsClient.uploadPart(bucketName, objectKey, partNumber, uploadId, object, isFile, partSize, offset, sseHeader, isAttachMd5, md5, progressCallback, autoClose, extensionHeaders)
+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

str

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+
NOTE:

The object URL is in the following format: https://Bucket name.Domain name/Folder directory level/Object name. If this object is stored in the root directory of the bucket, its URL does not contain the folder directory level.

+
+

partNumber

+

int

+

Yes

+

Explanation:

+

Part number

+

Value range:

+

[1,10000]

+

Default value:

+

None

+

uploadId

+

str

+

Yes

+

Explanation:

+

Multipart upload ID which can be returned by initiating a multipart upload, for example, 000001648453845DBB78F2340DD460D8

+

Restrictions:

+

The value must contain 32 characters.

+

Default value:

+

None

+

object

+

str or readable object

+

Yes

+

Explanation:

+

Part content to be uploaded

+

Value range:

+

A string or a readable object

+
NOTE:

If object is a readable object that contains the read attribute, data is read from the readable object. Otherwise, the object content is a string.

+
+

Default value:

+

None

+

isFile

+

bool

+

No

+

Explanation:

+

Whether object indicates the file path.

+

Value range:

+

True: object indicates the file path.

+

False: object does not indicate the file path.

+

Default value:

+

False

+

offset

+

int

+

No

+

Explanation:

+

Start offset of a part in the source file

+

Value range:

+

A non-negative integer not exceeding the size of the object to be uploaded, in bytes

+

Default value:

+

0

+

partSize

+

int

+

No

+

Explanation:

+

Part size

+

Restrictions:

+
  • Except for the last uploaded part, all parts must be larger than 100 KB. Part sizes will not be verified during upload because whether an uploaded part is the last one cannot be determined. Their sizes will be verified when being assembled.
  • The minimum part size supported by an OBS 3.0 bucket is 100 KB, and that supported by an OBS 2.0 bucket is 5 MB.
+

Value range:

+

The value ranges from 100 KB to 5 GB, in bytes.

+

Default value:

+

102400

+

sseHeader

+

SseCHeader

+

No

+

Explanation:

+

Server-side encryption header. For details, see Table 2.

+

Default value:

+

None

+

isAttachMd5

+

bool

+

No

+

Explanation:

+

Whether to automatically calculate the MD5 value of the data to be uploaded.

+

Restrictions:

+

If isAttachMd5 and md5 are used at the same time, isAttachMd5 is invalid.

+

Value range:

+

True: The MD5 value of the data to be uploaded is automatically calculated.

+

False: The MD5 value of the data to be uploaded is not automatically calculated.

+

Default value:

+

False

+

md5

+

str

+

No

+

Explanation:

+

Base64-encoded MD5 value of the part to be uploaded, which uniquely identifies the content of the uploaded part and can be used to identify whether the object content is changed.

+

Restrictions:

+

If isAttachMd5 and md5 are used at the same time, isAttachMd5 is invalid.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

progressCallback

+

callable

+

No

+

Explanation:

+

Callback function for obtaining the upload progress

+

Default value:

+

None

+
NOTE:

This callback function contains the following parameters in sequence: number of uploaded bytes, total bytes, and used time (in seconds).

+
+

autoClose

+

bool

+

No

+

Explanation:

+

Whether to automatically close data streams after the upload is complete

+

Value range:

+

True: The data stream is automatically closed.

+

False: The data stream is not automatically closed.

+

Default value:

+

True

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 2 SseCHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

encryption

+

str

+

Yes

+

Explanation:

+

SSE-C used for encrypting objects

+

Value range:

+

AES256

+

Default value:

+

None

+

key

+

str

+

Yes

+

Explanation:

+

Key used in SSE-C encryption. It corresponds to the encryption method. For example, if encryption is set to AES256, the key is calculated using the AES-256 algorithm.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + +
Table 3 List of returned results

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 4 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + +
Table 5 GetResult.body

GetResult.body Type

+

Description

+

UploadPartResponse

+

Explanation:

+

Response to the request for uploading a part

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Table 6 UploadPartResponse

Parameter

+

Type

+

Description

+

etag

+

str

+

Explanation:

+

Base64-encoded 128-bit MD5 digest of a part. ETag is the unique identifier of the part content. It can be used to determine whether the part content is changed.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

sseKms

+

str

+

Explanation:

+

SSE-KMS is used for encrypting objects on the server side.

+

Value range:

+

kms

+

Default value:

+

None

+

sseKmsKey

+

str

+

Explanation:

+

ID of the KMS master key when SSE-KMS is used

+

Value range:

+

Valid value formats are as follows:

+
  1. regionID:domainID:key/key_id
  2. key_id
+

In the preceding formats:

+ +

Default value:

+
  • If this parameter is not specified, the default master key will be used.
  • If there is no such a default master key, OBS will create one and use it by default.
+

sseC

+

str

+

Explanation:

+

Algorithm used to encrypt and decrypt objects with SSE-C

+

Value range:

+

AES256

+

Default value:

+

None

+

sseCKeyMd5

+

str

+

Explanation:

+

MD5 value of the key for encrypting objects when SSE-C is used. This value is used to check whether any error occurs during the transmission of the key.

+

Restrictions:

+

The value is encrypted by MD5 and then encoded by Base64, for example, 4XvB3tbNTN+tIEVa0/fGaQ==.

+

Default value:

+

None

+
+
+
+

Code Examples

This example uploads a part.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName = "examplebucket"
+    # Specify the name of the object to be uploaded to the bucket.
+    objectKey = "objectname"
+    # Specify the part number, which ranges from 1 to 10,000
+    partNumber = "your partNumber"
+    # Specify the ID of the multipart upload.
+    uploadId = "your uploadid"
+    # Specify the content of the part to be uploaded as a string or readable object.
+    object = 'Hello OBS'
+    # Specify whether object indicates the file path. The default value is False.
+    isFile = False
+    # Specify the start offset (in bytes) of a part in the source file. The default value is 0.
+    offset = 0
+    # Specify the size (in bytes) of a part in the source file. The default value is the file size minus offset.
+    partSize = 9 * 1024 * 1024
+    # Specify whether to automatically calculate the MD5 value of the data to be uploaded. The default value is False.
+    isAttachMd5 = True
+    # Upload the part to a specified bucket using the multipart upload ID.
+    resp = obsClient.uploadPart(bucketName, objectKey, partNumber, uploadId, object, isFile, partSize,
+                                offset, isAttachMd5=isAttachMd5)
+
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Upload Part Succeeded')
+        print('requestId:', resp.requestId)
+        print('etag:', resp.body.etag)
+    else:
+        print('Upload Part Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Upload Part Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_1004.html b/docs/obs_3rd_party/python_sdk/obs_22_1004.html new file mode 100644 index 000000000..02411fccc --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_1004.html @@ -0,0 +1,696 @@ + + +

Listing Uploaded Parts (SDK for Python)

+

Function

This API lists the uploaded parts in a specified bucket. This request must contain the multipart upload ID.

+

You can list the uploaded parts of a specified multipart upload or of all ongoing multipart uploads. A maximum of 1,000 uploaded parts can be returned in a response. If your multipart upload has more than 1,000 parts, you need to send multiple requests to list all uploaded parts. Assembled parts will not be listed.

+
+

Restrictions

+
+

Method

ObsClient.listParts(bucketName, objectKey, uploadId, maxParts, partNumberMarker, extensionHeaders)
+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

str

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+
NOTE:

The object URL is in the following format: https://Bucket name.Domain name/Folder directory level/Object name. If this object is stored in the root directory of the bucket, its URL does not contain the folder directory level.

+
+

uploadId

+

str

+

Yes

+

Explanation:

+

Multipart upload ID, for example, 000001648453845DBB78F2340DD460D8

+

Value range:

+

The value must contain 1 to 32 characters.

+

Default value:

+

None

+

maxParts

+

int

+

No

+

Explanation:

+

Maximum number of uploaded parts that can be listed per page

+

Restrictions:

+

If the specified value is greater than 1000, only 1,000 parts are returned.

+

Value range:

+

The value ranges from 1 to 1000.

+

Default value:

+

1000

+

partNumberMarker

+

int

+

No

+

Explanation:

+

Part number after which uploaded part listing begins

+

Restrictions:

+

OBS lists only parts with greater numbers than that specified by this parameter.

+

Default value:

+

None

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + +
Table 2 List of returned results

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + +
Table 4 GetResult.body

GetResult.body Type

+

Description

+

ListPartsResponse

+

Explanation:

+

Response to the request for listing uploaded parts

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 5 ListPartsResponse

Parameter

+

Type

+

Description

+

bucketName

+

str

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

str

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

uploadId

+

str

+

Explanation:

+

Multipart upload ID, for example, 000001648453845DBB78F2340DD460D8

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

initiator

+

Initiator

+

Explanation:

+

Initiator of the multipart upload. For details, see Table 7.

+

Default value:

+

None

+

owner

+

Owner

+

Explanation:

+

Owner of the multipart upload, which is consistent with initiator. For details, see Table 8.

+

Default value:

+

None

+

storageClass

+

str

+

Explanation:

+

Object storage class

+

Value range:

+

See Table 6.

+

Default value:

+

None

+

partNumberMarker

+

int

+

Explanation:

+

Part number after which part listing begins, which is consistent with that set in the request

+

Value range:

+

An integer greater than or equal to 0

+

Default value:

+

None

+

nextPartNumberMarker

+

int

+

Explanation:

+

Part number to start with for the next part listing request. nextPartNumberMarker is returned when not all the parts are listed. You can set partNumberMarker to this value in the next request to list the remaining parts.

+

Value range:

+

An integer greater than or equal to 0

+

Default value:

+

None

+

maxParts

+

int

+

Explanation:

+

Maximum number of parts that can be listed per page. This parameter is consistent with that set in the request.

+

Restrictions:

+

If the specified value is greater than 1000, only 1,000 parts are returned.

+

Value range:

+

The value ranges from 1 to 1000.

+

Default value:

+

1000

+

isTruncated

+

bool

+

Explanation:

+

Whether all results are returned in the response

+

Value range:

+
  • true: Not all results are returned.
  • false: All results are returned.
+

Default value:

+

None

+

parts

+

list of Part

+

Explanation:

+

List of uploaded parts. For details, see Table 9.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 6 StorageClass

Parameter

+

Type

+

Description

+

STANDARD

+

Standard storage class

+

Explanation:

+

Features low access latency and high throughput and is used for storing massive, frequently accessed (multiple times a month) or small objects (< 1 MB) requiring quick response.

+

WARM

+

Warm storage class

+

Explanation:

+

Used for storing data that is semi-frequently accessed (fewer than 12 times a year) but is instantly available when needed.

+

COLD

+

Cold storage class

+

Explanation:

+

Used for storing rarely accessed (once a year) data.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 7 Initiator

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

id

+

str

+

Yes if used as a request parameter

+

Explanation:

+

Account (domain) ID of the initiator

+

Value range:

+

+

Default value:

+

None

+

name

+

str

+

No if used as a request parameter

+

Explanation:

+

Account name of the initiator

+

Restrictions:

+

The account name can contain 6 to 32 characters and must start with a letter. Only letters, digits, hyphens (-), and underscores (_) are allowed.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 8 Owner

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

owner_id

+

str

+

Yes if used as a request parameter

+

Explanation:

+

Account (domain) ID of the owner

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and IAM User ID? (SDK for Python)

+

Default value:

+

None

+

owner_name

+

str

+

No if used as a request parameter

+

Explanation:

+

Account name of the owner

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and IAM User ID? (SDK for Python)

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 9 Part

Parameter

+

Type

+

Description

+

partNumber

+

int

+

Explanation:

+

Part number

+

Value range:

+

An integer ranging from 1 to 10000

+

Default value:

+

None

+

lastModified

+

str

+

Explanation:

+

Time when the part was last modified

+

Default value:

+

None

+

etag

+

str

+

Explanation:

+

Part ETag, which is a Base64-encoded, 128-bit MD5 value

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

size

+

int

+

Explanation:

+

Part size

+

Default value:

+

None

+
+
+
+

Code Examples

This example lists the parts that have been uploaded in a multipart upload.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName = "examplebucket"
+    objectKey = "objectname"
+    # Specify the ID of the multipart upload.
+    uploadId = "your uploadid"
+    # Specify the maximum number (10 as an example) of parts that can be listed per page.
+    maxParts = 10
+    # List the uploaded parts.
+    resp = obsClient.listParts(bucketName, objectKey, uploadId, maxParts, encoding_type='url')
+
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('List Parts Succeeded')
+        print('requestId:', resp.requestId)
+        print('bucketName:', resp.body.bucketName)
+        print('objectKey:', resp.body.objectKey)
+        print('uploadId:', resp.body.uploadId)
+        print('storageClass:', resp.body.storageClass)
+        print('isTruncated:', resp.body.isTruncated)
+        print('initiator:', resp.body.initiator)
+        print('owner:', resp.body.owner)
+
+        index = 1
+        for part in resp.body.parts:
+            print('part [' + str(index) + ']')
+            print('partNumber:', part.partNumber)
+            print('lastModified:', part.lastModified)
+            print('etag:', part.etag)
+            print('size:', part.size)
+            index += 1
+    else:
+        print('List Parts Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('List Parts Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_1005.html b/docs/obs_3rd_party/python_sdk/obs_22_1005.html new file mode 100644 index 000000000..593dc39a4 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_1005.html @@ -0,0 +1,793 @@ + + +

Listing Multipart Uploads (SDK for Python)

+

Function

This API lists ongoing multipart uploads.

+

Ongoing multipart uploads are the multipart uploads that have been initiated but have not been completed or aborted. A maximum of 1,000 multipart uploads can be returned in a response. If there are over 1,000 ongoing tasks satisfying the list criteria, you need to send more requests to query additional multipart uploads.

+
+

Restrictions

+
+

Method

ObsClient.listMultipartUploads(bucketName, multipart, extensionHeaders)
+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucket

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

multipart

+

ListMultipartUploadsRequest

+

No

+

Explanation:

+

Request parameters for listing multipart uploads. For details, see Table 2.

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 ListMultipartUploadsRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

prefix

+

str

+

No

+

Explanation:

+

Name prefix that the objects in the multipart uploads to be listed must contain

+

Assume that you have the following objects: logs/day1, logs/day2, logs/day3, and ExampleObject.jpg. If you specify logs/ as the prefix, the multipart uploads of logs/day1, logs/day2, and logs/day3 will be returned. If you leave this parameter blank, all multipart uploads in the bucket will be returned.

+

Restrictions:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

max_uploads

+

int

+

or

+

str

+

No

+

Explanation:

+

Maximum number of listed multipart uploads

+

Restrictions:

+

If the specified value is greater than 1000, only 1,000 multipart uploads are returned.

+

Value range:

+

An integer from 1 to 1000

+

Default value:

+

1000

+

delimiter

+

str

+

No

+

Explanation:

+

Object names are grouped by this parameter, which is often used with prefix. If a prefix is specified, objects with the same string from the prefix to the first delimiter are grouped into one CommonPrefix. If no prefix is specified, objects with the same string from the first character to the first delimiter are grouped into one CommonPrefix.

+

Assume that a bucket has objects abcd, abcde, and bbcde in it. If delimiter is set to d and prefix is set to a, objects abcd and abcde are grouped into a CommonPrefix with abcd as the prefix. If only delimiter is set to d, objects abcd and abcde are grouped into a CommonPrefix with abcd as the prefix, and bbcde is grouped separately into another CommonPrefix with bbcd as the prefix.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

key_marker

+

str

+

No

+

Explanation:

+

Object name after which the multipart upload listing begins

+

Value range:

+

The value of nextKeyMarker in the response body of the last request

+

Default value:

+

None

+

upload_id_marker

+

str

+

No

+

Explanation:

+

Upload ID after which the multipart upload listing begins

+

Restrictions:

+

This parameter is valid only when used with key_marker. If both parameters are specified, multipart uploads with IDs greater than the specified uploadIdMarker for the specified keyMarker are listed.

+

Value range:

+

The value of nextUploadIdMarker in the response body of the last request

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + +
Table 3 List of returned results

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 4 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + +
Table 5 GetResult.body

GetResult.body Type

+

Description

+

ListMultipartUploadsResponse

+

Explanation:

+

Response to the request for listing multipart uploads

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 6 ListMultipartUploadsResponse

Parameter

+

Type

+

Description

+

bucket

+

str

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

keyMarker

+

str

+

Explanation:

+

Object name after which the multipart upload listing begins, which is consistent with that set in the request.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

uploadIdMarker

+

str

+

Explanation:

+

Upload ID after which the multipart upload listing begins, which is consistent with that set in the request

+

Value range:

+

The value must contain 1 to 32 characters.

+

Default value:

+

None

+

nextKeyMarker

+

str

+

Explanation:

+

Object name to start with for the next multipart upload listing request. nextKeyMarker is returned when not all the objects are listed. You can set key_marker to this value in the next request to list the remaining multipart uploads.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

nextUploadIdMarker

+

str

+

Explanation:

+

Upload ID to start with for the next multipart upload listing request. This parameter is used together with nextKeyMarker. nextUploadIdMarker is returned when not all the objects are listed. You can set upload_id_marker to this value in the next request to list the remaining multipart uploads.

+

Value range:

+

The value must contain 1 to 32 characters.

+

Default value:

+

None

+

maxUploads

+

int

+

Explanation:

+

Maximum number of listed multipart uploads, which is consistent with that in the request

+

Restrictions:

+

If the specified value is greater than 1000, only 1,000 multipart uploads are returned.

+

Value range:

+

An integer from 1 to 1000

+

Default value:

+

1000

+

isTruncated

+

bool

+

Explanation:

+

Whether all results are returned in the response

+

Value range:

+
  • true: Not all results are returned.
  • false: All results are returned.
+

Default value:

+

None

+

prefix

+

str

+

Explanation:

+

Prefix that the object names in the multipart uploads to be listed must contain. This parameter is consistent with that set in the request.

+

Assume that you have the following objects: logs/day1, logs/day2, logs/day3, and ExampleObject.jpg. If you specify logs/ as the prefix, the multipart uploads of logs/day1, logs/day2, and logs/day3 will be returned. If you leave this parameter blank, all multipart uploads in the bucket will be returned.

+

Restrictions:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

delimiter

+

str

+

Explanation:

+

A character used to group object names in multipart uploads, which is consistent with that set in the request. This parameter is often used with prefix. If a prefix is specified, objects with the same string from the prefix to the first delimiter are grouped into one CommonPrefixes. If no prefix is specified, objects with the same string from the first character to the first delimiter are grouped into one CommonPrefixes.

+

Assume that a bucket has objects abcd, abcde, and bbcde in it. If delimiter is set to d and prefix is set to a, objects abcd and abcde are grouped into a CommonPrefixes with abcd as the prefix. If only delimiter is set to d, objects abcd and abcde are grouped into a CommonPrefixes with abcd as the prefix, and bbcde is grouped separately into another CommonPrefixes with bbcd as the prefix.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

upload

+

list of Upload

+

Explanation:

+

List of multipart uploads. For details, see Table 7.

+

Default value:

+

None

+

commonPrefixs

+

list of CommonPrefix

+

Explanation:

+

List of object name prefixes grouped according to the delimiter parameter (if specified)

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 7 Upload

Parameter

+

Type

+

Description

+

key

+

str

+

Explanation:

+

Name of the object to be uploaded. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

uploadId

+

str

+

Explanation:

+

Multipart upload ID, for example, 000001648453845DBB78F2340DD460D8

+

Value range:

+

The value must contain 1 to 32 characters.

+

Default value:

+

None

+

initiator

+

Initiator

+

Explanation:

+

Initiator of the multipart upload. For details, see Table 9.

+

Default value:

+

None

+

owner

+

Owner

+

Explanation:

+

Owner of the multipart upload, which is consistent with initiator. For details, see Table 10.

+

Default value:

+

None

+

storageClass

+

str

+

Explanation:

+

Storage class of the object to be uploaded

+

Value range:

+

See Table 11.

+

Default value:

+

None

+

initiated

+

str

+

Explanation:

+

Time when the multipart upload is initiated

+

Restrictions:

+

The time must be in the ISO8601 format, for example, 2018-01-01T00:00:00.000Z.

+

Sample code: DateTime(year=2023, month=9, day=12)

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + +
Table 8 CommonPrefix

Parameter

+

Type

+

Description

+

prefix

+

str

+

Explanation:

+

List of object name prefixes grouped according to the delimiter parameter (if specified)

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 9 Initiator

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

id

+

str

+

Yes if used as a request parameter

+

Explanation:

+

Account (domain) ID of the initiator

+

Value range:

+

+

Default value:

+

None

+

name

+

str

+

No if used as a request parameter

+

Explanation:

+

Account name of the initiator

+

Restrictions:

+

The account name can contain 6 to 32 characters and must start with a letter. Only letters, digits, hyphens (-), and underscores (_) are allowed.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 10 Owner

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

owner_id

+

str

+

Yes if used as a request parameter

+

Explanation:

+

Account (domain) ID of the owner

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and IAM User ID? (SDK for Python)

+

Default value:

+

None

+

owner_name

+

str

+

No if used as a request parameter

+

Explanation:

+

Account name of the owner

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and IAM User ID? (SDK for Python)

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 11 StorageClass

Parameter

+

Type

+

Description

+

STANDARD

+

Standard storage class

+

Explanation:

+

Features low access latency and high throughput and is used for storing massive, frequently accessed (multiple times a month) or small objects (< 1 MB) requiring quick response.

+

WARM

+

Warm storage class

+

Explanation:

+

Used for storing data that is semi-frequently accessed (fewer than 12 times a year) but is instantly available when needed.

+

COLD

+

Cold storage class

+

Explanation:

+

Used for storing rarely accessed (once a year) data.

+
+
+
+

Code Examples

This example lists multipart uploads in a bucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
from obs import ObsClient
+from obs import ListMultipartUploadsRequest
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName = "examplebucket"
+    # Specify the prefix that the object names in the multipart uploads to be listed must contain.
+    prefix = 'prefix'
+    # Specify the maximum number (10 as an example) of returned multipart uploads. The value ranges from 1 to 1,000. If the value is not in this range, 1,000 is returned by default.
+    max_uploads = 10
+    # Specify request parameters for listing multipart uploads.
+    multipart = ListMultipartUploadsRequest(prefix=prefix, max_uploads=max_uploads)
+    # List multipart uploads in a bucket.
+    resp = obsClient.listMultipartUploads(bucketName, multipart, encoding_type='url')
+
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('List Multipart Uploads Succeeded')
+        print('requestId:', resp.requestId)
+        print('bucket:', resp.body.bucket)
+        print('prefix:', resp.body.prefix)
+        print('maxUploads:', resp.body.maxUploads)
+        print('isTruncated:', resp.body.isTruncated)
+        index = 1
+        for upload in resp.body.upload:
+            print('upload [' + str(index) + ']')
+            print('key:', upload.key)
+            print('uploadId:', upload.uploadId)
+            print('storageClass:', upload.storageClass)
+            print('initiated:', upload.initiated)
+            print('owner_id:', upload.owner.owner_id)
+            print('owner_name:', upload.owner.owner_name)
+            index += 1
+    else:
+        print('List Multipart Uploads Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('List Multipart Uploads Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_1006.html b/docs/obs_3rd_party/python_sdk/obs_22_1006.html new file mode 100644 index 000000000..e5b8f3465 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_1006.html @@ -0,0 +1,547 @@ + + +

Assembling Parts (SDK for Python)

+

Function

This API assembles the uploaded parts to complete the multipart upload. Before performing this operation, you cannot download the uploaded data. When assembling parts, you need to copy the additional message header information recorded during the multipart upload initiation to the object metadata. Such information is processed the same way the information in a common object upload is processed. In the case of assembling parts concurrently, last write wins is applied, but the time of last write is defined as the time when a multipart upload was initiated.

+

As long as the multipart upload is not aborted, all uploaded parts occupy the space. However, after you assembled the specified parts, those uploaded but not assembled will be deleted to free up space.

+

When assembling parts, OBS creates an object by putting part numbers in ascending order. If any object metadata is provided in the initiation of the multipart upload, OBS will associate the metadata with the object. After the multipart upload is complete, the parts will no longer exist. A part assembling request must contain the upload ID, part numbers, and a list of corresponding ETag values. In response to the request, the ETag that uniquely identifies the assembled parts is contained. This ETag is not the MD5 hash value of the entire object.

+
+

Restrictions

+
+

Method

ObsClient.completeMultipartUpload(bucketName, objectKey, uploadId, completeMultipartUploadRequest, extensionHeaders)
+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

str

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+
NOTE:

The object URL is in the following format: https://Bucket name.Domain name/Folder directory level/Object name. If this object is stored in the root directory of the bucket, its URL does not contain the folder directory level.

+
+

uploadId

+

str

+

Yes

+

Explanation:

+

Multipart upload ID, for example, 000001648453845DBB78F2340DD460D8

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

completeMultipartUploadRequest

+

CompleteMultipartUploadRequest

+

Yes

+

Explanation:

+

Request parameters for assembling parts. For details, see Table 2.

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + +
Table 2 CompleteMultipartUploadRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

parts

+

list of CompletePart

+

Yes

+

Explanation:

+

List of parts to be assembled. For details, see Table 3.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 3 CompletePart

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

partNum

+

int

+

Yes

+

Explanation:

+

Part number

+

Value range:

+

[1,10000]

+

Default value:

+

None

+

etag

+

str

+

Yes

+

Explanation:

+

ETag of a part. It is calculated by encoding the 128-bit MD5 value of the part using Base64.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + +
Table 4 List of returned results

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 5 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + +
Table 6 GetResult.body

GetResult.body Type

+

Description

+

CompleteMultipartUploadResponse

+

Explanation:

+

Response to the request for assembling parts. For details, see Table 7.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 7 CompleteMultipartUploadResponse

Parameter

+

Type

+

Description

+

etag

+

str

+

Explanation:

+

The ETag that uniquely identifies the object after its parts were assembled, calculated based on the ETag of each part.

+

Restrictions:

+

If an object is encrypted using server-side encryption, the ETag is not the MD5 value of the object.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

bucket

+

str

+

Explanation:

+

Bucket in which parts are assembled

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

key

+

str

+

Explanation:

+

Object name obtained after part assembling.

+

An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

location

+

str

+

Explanation:

+

URL of the generated object after part assembling

+

Default value:

+

None

+

versionId

+

str

+

Explanation:

+

Version ID of the object obtained after part assembling

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

sseKms

+

str

+

Explanation:

+

SSE-KMS algorithm

+

Value range:

+

kms

+

Default value:

+

None

+

sseKmsKey

+

str

+

Explanation:

+

ID of the KMS master key when SSE-KMS is used

+

Value range:

+

Valid value formats are as follows:

+
  1. regionID:domainID:key/key_id
  2. key_id
+

In the preceding formats:

+ +

Default value:

+
  • If this parameter is not specified, the default master key will be used.
  • If there is no such a default master key, OBS will create one and use it by default.
+

sseC

+

str

+

Explanation:

+

SSE-C algorithm

+

Value range:

+

AES256

+

Default value:

+

None

+

sseCKeyMd5

+

str

+

Explanation:

+

MD5 value of the key for encrypting objects when SSE-C is used. This value is used to check whether any error occurs during the transmission of the key.

+

Restrictions:

+

The value is encrypted by MD5 and then encoded by Base64, for example, 4XvB3tbNTN+tIEVa0/fGaQ==.

+

Default value:

+

None

+

objectUrl

+

str

+

Explanation:

+

Full path to the obtained object after part assembling

+

Default value:

+

None

+
+
+
+

Code Examples

This example assembles the parts previously uploaded to a bucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
from obs import ObsClient
+from obs import CompleteMultipartUploadRequest, CompletePart
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    # Specify the list of parts to be assembled by configuring completeMultipartUploadRequest. Each part contains partNum and etag.
+    part1 = CompletePart(partNum=1, etag='etag1')
+    part2 = CompletePart(partNum=2, etag='etag2')
+    completeMultipartUploadRequest = CompleteMultipartUploadRequest(parts=[part1, part2])
+
+    bucketName = "examplebucket"
+    objectKey = "objectname"
+    # Specify the ID of the multipart upload.
+    uploadId = "your uploadid"
+    # Assemble the parts uploaded to the bucket.
+    resp = obsClient.completeMultipartUpload(bucketName, objectKey, uploadId, completeMultipartUploadRequest, encoding_type='url')
+
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Complete Multipart Upload Succeeded')
+        print('requestId:', resp.requestId)
+        print('etag:', resp.body.etag)
+        print('bucket:', resp.body.bucket)
+        print('key:', resp.body.key)
+        print('location:', resp.body.location)
+        print('versionId:', resp.body.versionId)
+    else:
+        print('Complete Multipart Upload Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Complete Multipart Upload Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_1007.html b/docs/obs_3rd_party/python_sdk/obs_22_1007.html new file mode 100644 index 000000000..4f5add866 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_1007.html @@ -0,0 +1,569 @@ + + +

Copying a Part (SDK for Python)

+

Function

This API copies a part to a specified bucket. This request must contain the multipart upload ID.

+

After creating a multipart upload, you can specify the upload ID and upload parts for the multipart upload. Alternatively, you can call this API to copy part or all of an uploaded object as a part.

+

Assume that you copy a source object and save it as part1. If there is already a part1 before the copy, the new part1 will overwrite the existing part1. Then, only the new part1 can be listed and the old part1 is deleted. Therefore, when using this API, ensure that the target part does not exist or is no longer used, to avoid accidental deletion. The source object keeps unchanged in the entire copy process.

+
+

Restrictions

+
+

Method

ObsClient.copyPart(bucketName, objectKey, partNumber, uploadId, copySource, copySourceRange, destSseHeader, sourceSseHeader, extensionHeaders)
+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Target bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

str

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+
NOTE:

The object URL is in the following format: https://Bucket name.Domain name/Folder directory level/Object name. If this object is stored in the root directory of the bucket, its URL does not contain the folder directory level.

+
+

partNumber

+

int

+

Yes

+

Explanation:

+

Part number

+

Value range:

+

[1,10000]

+

Default value:

+

None

+

uploadId

+

str

+

Yes

+

Explanation:

+

Multipart upload ID, for example, 000001648453845DBB78F2340DD460D8

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

copySource

+

str

+

Yes

+

Explanation:

+

Parameter used to specify the source bucket, source object, and source object version ID which can be left blank. It is in the format of SourceBucketName/SourceObjectName?versionId=SourceObjectVersionId.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
  • An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.
+

Default value:

+

None

+

copySourceRange

+

str

+

No

+

Explanation:

+

Copy source range. For example, 0-999 indicates the range is from byte 1 to byte 1,000.

+

Value range:

+

Value range: 0 to the object length minus 1. Format: x-y, indicating the range is from byte x+1 to byte y+1

+

Restrictions:

+

The upper limit of range is the length of the object minus 1. If the specified value exceeds this limit, the length of the object minus 1 is used.

+

Default value:

+

None

+

destSseHeader

+

SseCHeader or SseKmsHeader

+

No

+

Explanation:

+

Server-side encryption header used for encrypting the target object. For details, see Table 2 or Table 3.

+

sourceSseHeader

+

SseCHeader

+

No

+

Explanation:

+

Server-side decryption header used for decrypting the source object. For details, see Table 2.

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 2 SseCHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

encryption

+

str

+

Yes

+

Explanation:

+

SSE-C used for encrypting objects

+

Value range:

+

AES256

+

Default value:

+

None

+

key

+

str

+

Yes

+

Explanation:

+

Key used in SSE-C encryption. It corresponds to the encryption method. For example, if encryption is set to AES256, the key is calculated using the AES-256 algorithm.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 3 SseKmsHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

encryption

+

str

+

Yes

+

Explanation:

+

SSE-KMS used for encrypting objects

+

Value range:

+

kms

+

Default value:

+

None

+

key

+

str

+

No

+

Explanation:

+

Master key used in SSE-KMS

+

Value range:

+

The following two formats are supported:

+
  • regionID:domainID:key/key_id
  • key_id
+

In the preceding formats:

+ +

Default value:

+
  • If this parameter is not specified, the default master key will be used.
  • If there is no such a default master key, OBS will create one and use it by default.
+
+
+
+

Responses

+
+ + + + + + + +
Table 4 List of returned results

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 5 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+ +
+ + + + + + + +
Table 6 GetResult.body

GetResult.body Type

+

Description

+

CopyPartResponse

+

Explanation:

+

Response to the request for copying a part. For details, see Table 7.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 7 CopyPartResponse

Parameter

+

Type

+

Description

+

etag

+

str

+

Explanation:

+

Base64-encoded 128-bit MD5 digest of a part. ETag is the unique identifier of the part content. It can be used to determine whether the part content is changed.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

lastModified

+

str

+

Explanation:

+

Time when the last modification was made to the object

+

Restrictions:

+

The time must be in the GMT format, for example, Wed, 25 Mar 2020 02:39:52 GMT.

+

Default value:

+

None

+

sseKms

+

str

+

Explanation:

+

SSE-KMS is used for encrypting objects on the server side.

+

Value range:

+

kms

+

Default value:

+

None

+

sseKmsKey

+

str

+

Explanation:

+

ID of the KMS master key when SSE-KMS is used

+

Value range:

+

Valid value formats are as follows:

+
  1. regionID:domainID:key/key_id
  2. key_id
+

In the preceding formats:

+ +

Default value:

+
  • If this parameter is not specified, the default master key will be used.
  • If there is no such a default master key, OBS will create one and use it by default.
+

sseC

+

str

+

Explanation:

+

Algorithm used to encrypt and decrypt objects with SSE-C

+

Value range:

+

AES256

+

Default value:

+

None

+

sseCKeyMd5

+

str

+

Explanation:

+

MD5 value of the key for encrypting objects when SSE-C is used. This value is used to check whether any error occurs during the transmission of the key.

+

Restrictions:

+

The value is encrypted by MD5 and then encoded by Base64, for example, 4XvB3tbNTN+tIEVa0/fGaQ==.

+

Default value:

+

None

+
+
+
+

Code Examples

This example copies parts from one bucket to another.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName = "examplebucket"
+    objectKey = "objectname"
+    # Specify the part number, which ranges from 1 to 10,000
+    partNumber = "your partNumber"
+    # Specify the ID of the multipart upload.
+    uploadId = "your uploadid"
+    # Specify the source bucket, source object, and source object version ID (optional). The format is source-bucket-name/source-object-name?versionId=source-object-versionId.
+    copySource = 'sourcebucketname/sourceobjectkey'
+    # [Optional] Specify the copy scope in the format of x-y. Value range: [0, source-object-length – 1].
+    # copySourceRange = '0-15'
+    # Copy the part to the specified bucket using the multipart upload ID.
+    resp = obsClient.copyPart(bucketName, objectKey, partNumber, uploadId, copySource)
+
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Copy Part Succeeded')
+        print('requestId:', resp.requestId)
+        print('etagValue:', resp.body.etagValue)
+        print('modifiedDate:', resp.body.modifiedDate)
+    else:
+        print('Copy Part Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Copy Part Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_1008.html b/docs/obs_3rd_party/python_sdk/obs_22_1008.html new file mode 100644 index 000000000..5c8e892ef --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_1008.html @@ -0,0 +1,297 @@ + + +

Aborting a Multipart Upload (SDK for Python)

+

Function

This API aborts a multipart upload using the multipart upload ID.

+

After a multipart upload is aborted, the upload ID cannot be used to upload any part. The storage occupied by any uploaded parts will be released. If any part uploads are in progress, aborting the multipart upload might or might not make the uploads successful. To release the storage occupied by all uploaded parts, you can only abort the multipart upload after all parts have been uploaded.

+
+

Restrictions

+
+

Method

ObsClient.abortMultipartUpload(bucketName, objectKey, uploadId, extensionHeaders)
+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

str

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+
NOTE:

The object URL is in the following format: https://Bucket name.Domain name/Folder directory level/Object name. If this object is stored in the root directory of the bucket, its URL does not contain the folder directory level.

+
+

uploadId

+

str

+

Yes

+

Explanation:

+

Multipart upload ID, for example, 000001648453845DBB78F2340DD460D8

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

extensionHeaders

+

dict

+

No

+

Explanation:

+

Extension headers.

+

Value range:

+

See User-defined Header (SDK for Python).

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + +
Table 2 List of returned results

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+
+

Code Examples

This example aborts a multipart upload.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName = "examplebucket"
+    objectKey = "objectname"
+    # Specify the ID of the multipart upload.
+    uploadId = "your uploadid"
+    # Abort the multipart upload.
+    resp = obsClient.abortMultipartUpload(bucketName, objectKey, uploadId)
+
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Abort Multipart Upload Succeeded')
+        print('requestId:', resp.requestId)
+    else:
+        print('Abort Multipart Upload Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Abort Multipart Upload Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_1009.html b/docs/obs_3rd_party/python_sdk/obs_22_1009.html new file mode 100644 index 000000000..a70fbd279 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_1009.html @@ -0,0 +1,17 @@ + + + +

Client-Side Encryption APIs (SDK for Python)

+ +

+
+ +
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_1010.html b/docs/obs_3rd_party/python_sdk/obs_22_1010.html new file mode 100644 index 000000000..d161e59fe --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_1010.html @@ -0,0 +1,173 @@ + + +

Introduction (SDK for Python)

+

Client-side encryption is a process where data is encrypted using the selected encryption method and information on your local PC before it is transmitted to an OBS server. During this process, the encryption method used and necessary information required for decryption will be stored in object metadata. During a download, the OBS SDK decrypts the data based on the key provided and the information stored in object metadata, and then returns the decrypted data.

+

+
  • OBS does not store your master key in any way. Keep your master key correct and intact. If your master key is lost or mistakenly used, your data cannot be decrypted.
  • Do not modify the information required for decryption in object metadata when moving or replicating an encrypted object or modifying the object metadata. If you do so, your data cannot be decrypted.
+
+

Encryption Process and Cipher Suites

The OBS Python SDK offers two cipher suite generators: CTRCipherGenerator based on AES-CTR and CtrRSACipherGenerator based on RSA and AES-CTR.

+

If CTRCipherGenerator is used to upload objects, you need to provide a data key. The SDK then randomly generates an initial value for each object and uses the data key and initial value to encrypt the object. After the encryption, the SDK uploads the encrypted object to OBS and stores its initial value in object metadata. To download this object, you need to provide the corresponding data key. The SDK then automatically obtains the initial value from object metadata, uses the data key provided and initial value to decrypt the object, and returns the decrypted data. If a different data key is provided for download, the SDK returns an unavailable decrypted file.

+

+

If CtrRSACipherGenerator is used to upload objects, you need to provide an RSA public or private key. The SDK then randomly generates a data key and initial value for each object and uses the data key and initial value to encrypt the object. After that, the SDK uploads the encrypted object to OBS and then uses the RSA key to encrypt the data key. The encrypted data key and initial value are stored in the object metadata. To download this object, you need to provide the same RSA public or private key as you provided for the upload. The SDK then automatically obtains the data key and initial value stored in the object metadata and uses the provided key to decrypt the data key. If the provided key does not match the key used for the upload, an error will be reported. After the data key is decrypted, the SDK uses the decrypted data key and initial value to decrypt the object and returns the decrypted data.

+
+

API Changes

CryptoObsClient is inherited from ObsClient. Except the APIs listed in the following table, all other APIs of CryptoObsClient are the same as those of ObsClient.

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1

API

+

ObsClient API Action

+

CryptoObsClient API Action

+

appendObject

+

Append data to an object.

+

Report an error.

+

copyPart

+

Copy an object part.

+

Report an error.

+

initiateMultipartUpload

+

Initialize a multipart upload.

+

Report an error.

+

uploadPart

+

Upload object parts.

+

Report an error.

+

putContent

+

Upload streams or texts.

+

Encrypt streams or texts and then upload them to OBS.

+

putFile

+

Upload common files to OBS.

+

Encrypt common files and then upload them to OBS.

+

getObject

+

Download files.

+

Decrypt files and then return the decrypted data.

+

uploadFile

+

Upload files in resumable mode to OBS.

+

Encrypt files and then upload them in resumable mode to OBS.

+

downloadFile

+

Download files in resumable mode to your local PC.

+

Decrypt files and then download them in resumable mode to your local PC.

+

initiateEncryptedMultipartUpload

+

None

+

Initialize an encrypted multipart upload.

+

uploadEncryptedPart

+

None

+

Encrypt uploaded parts.

+
+
+
+

Decryption Information in Metadata

The SDK saves the information required for decryption to the custom metadata of an object and does not back it up. If you modify the stored information, data cannot be decrypted. The table below describes the information required for decryption.

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2

Parameter

+

Mandatory (Yes/No)

+

Description

+

encrypted-algorithm

+

Yes

+

Information about a cipher suite

+

encrypted-object-key

+

Yes (when CtrRSACipherGenerator is used)

+

Data key encrypted using an RSA key

+

encrypted-start

+

Yes

+

String initially encoded using Base64. It is used to encrypt an object.

+

master-key-info

+

No

+

Information about an encryption key

+

plaintext-sha256

+

No

+

SHA-256 value of an object before encryption

+

plaintext-content-length

+

No

+

Object length before encryption

+

encrypted-sha256

+

No

+

SHA-256 of an encrypted object

+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_1011.html b/docs/obs_3rd_party/python_sdk/obs_22_1011.html new file mode 100644 index 000000000..51c912ecd --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_1011.html @@ -0,0 +1,370 @@ + + +

Client-Side Encryption (SDK for Python)

+

Initializing CryptoCipher

The OBS SDK for Python offers two types of CryptoCipher. Choose the one right for you.

+

CtrRSACipherGenerator needs an RSA public or private key to encrypt the randomly generated data key.

+

Method

+
CtrRSACipherGenerator(master_crypto_key_path, master_key_info=None, need_sha256=False)
+

+

API Parameters

+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 1 CtrRSACipherGenerator

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

master_crypto_key_path

+

str

+

Yes

+

Explanation:

+

Path where the RSA key file is stored

+

Default value:

+

None

+

master_key_info

+

str

+

No

+

Explanation:

+

Key information, which is stored in the custom metadata of objects to help you distinguish different data keys. You need to maintain the mapping between master_key_info and crypto_key.

+

Default value:

+

None

+

need_sha256

+

bool

+

No

+

Explanation:

+

Whether to verify the SHA-256 value of the encrypted data and to add SHA-256 values calculated before and after the encryption to the custom metadata

+
NOTE:

To reduce memory overheads, the SDK uses streaming computing, which means that a file needs to be read and encrypted twice in a common upload and three times in a resumable upload.

+
+

Value range:

+

True: The SHA-256 value of the encrypted data is verified. The SDK automatically calculates SHA-256 before and after the object is encrypted and saves the two values to the custom metadata of the object. In addition, the SDK adds the SHA-256 value of the encrypted object to the request header when sending a request to the server. After receiving the request, the server calculates the SHA-256 value of the object and checks the consistency between the calculated and the received values. If they are inconsistent, an error message is returned.

+

False: The SHA-256 value of the encrypted data is not verified.

+

Default value:

+

False

+
+
+

+

CTRCipherGenerator requires only a data key. This key is used to encrypt all objects.

+

Method

+
CTRCipherGenerator(crypto_key, master_key_info=None, crypto_iv=None, need_sha256=False)
+

+

API Parameters

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 CTRCipherGenerator

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

crypto_key

+

str or bytes

+

Yes

+

Explanation:

+

Data key used for encrypting data

+

Restrictions:

+
  • Length: 32 bytes
  • If a character string is passed, it is converted to bytes.
+

Default value:

+

None

+

master_key_info

+

str

+

No

+

Explanation:

+

Key information, which is stored in the custom metadata of objects to help you distinguish different data keys. You need to maintain the mapping between master_key_info and crypto_key.

+

Default value:

+

None

+

crypto_iv

+

str or bytes

+

No

+

Explanation:

+

Initial value used for encrypting data

+

Restrictions:

+
  • Length: 16 bytes
  • If crypto_iv is specified, all objects are encrypted using the specified initial value. If crypto_iv is not specified, the SDK randomly generates an initial value for each object.
+

Default value:

+

None

+

need_sha256

+

bool

+

No

+

Explanation:

+

Whether to verify the SHA-256 value of the encrypted data and to add SHA-256 values calculated before and after the encryption to the custom metadata

+
NOTE:

To reduce memory overheads, the SDK uses streaming computing, which means that a file needs to be read and encrypted twice during a common upload, but in a resumable upload, a file needs to be read and encrypted three times.

+
+

Value range:

+

True: The SHA-256 value of the encrypted data is verified. The SDK automatically calculates SHA-256 before and after the object is encrypted and saves the two values to the custom metadata of the object. In addition, the SDK adds the SHA-256 value of the encrypted object to the request header when sending a request to the server. After receiving the request, the server calculates the SHA-256 value of the object and checks the consistency between the calculated and the received values. If they are inconsistent, an error message is returned.

+

False: The SHA-256 value of the encrypted data is not verified.

+

Default value:

+

False

+
+
+
+

Initializing CryptoClient

Initializing CryptoClient is inherited from initializing an ObsClient. For details, see Initializing an Instance of ObsClient (SDK for Python).

+

Method

+
+
CryptoClient(access_key_id,secret_access_key,server,cipher_generator=your-cipher_generator, *args, **kwargs)
+

+

API Parameters

+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 3 List of request parameters

Parameter

+

Description

+

Recommended Value

+

access_key_id

+

Explanation:

+

Access key ID (AK)

+

Default value:

+

An empty string, indicating an anonymous user

+

N/A

+

secret_access_key

+

Explanation:

+

Secret access key (SK)

+

Default value:

+

An empty string, indicating an anonymous user

+

N/A

+

server

+

Explanation:

+

Server address for accessing OBS. It consists of a protocol type, domain name, and port number, for example, https://your-endpoint:443. For security purposes, you are advised to use HTTPS.

+

Default value:

+

None

+

N/A

+

cipher_generator

+

Explanation:

+

Cipher generator used by a client

+

Value range:

+ +

Default value:

+

None

+

N/A

+
+
+

Initiating an Encrypted Multipart Upload

Initiating an encrypted multipart upload is inherited from the ObsClient API for initiating a multipart upload. For details, see Initiating a Multipart Upload (SDK for Python).

+

Method

+
+
CryptoClient.initiateEncryptedMultipartUpload(bucketName, objectKey, crypto_cipher, *args, **kwargs)
+

+

API Parameters

+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 4 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

str

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+
NOTE:

The object URL is in the following format: https://Bucket name.Domain name/Folder directory level/Object name. If this object is stored in the root directory of the bucket, its URL does not contain the folder directory level.

+
+

crypto_cipher

+

OBSCipher

+

Yes

+

Explanation:

+

OBS cipher generated by calling cipher_generator.new(). Configure this parameter into the metadata during task initiation.

+

Value range:

+

A value generated by calling cipher_generator.new(). cipher_generator is the cipher_generator parameter set for CryptoClient initialization.

+

Example: cipher = ctr_client.cipher_generator.new(""). ctr_client is the encryption client.

+

Default value:

+

None

+
+
+

Uploading an Encrypted Part

Uploading encrypted parts is inherited from the ObsClient API for uploading parts. For details, see Uploading a Part (SDK for Python).

+

+

Method

+
CryptoClient.initiateEncryptedMultipartUpload(bucketName, objectKey, partNumber, uploadId, crypto_cipher, *args, **kwargs)
+

+

API Parameters

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 5 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

Yes

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

str

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+
NOTE:

The object URL is in the following format: https://Bucket name.Domain name/Folder directory level/Object name. If this object is stored in the root directory of the bucket, its URL does not contain the folder directory level.

+
+

partNumber

+

int

+

Yes

+

Explanation:

+

Part number

+

Value range:

+

[1,10000]

+

Default value:

+

None

+

uploadId

+

str

+

Yes

+

Explanation:

+

Multipart upload ID, which can be returned by initiating a multipart upload, for example, 000001648453845DBB78F2340DD460D8

+

Restrictions:

+

The value must contain 32 characters.

+

Default value:

+

None

+

crypto_cipher

+

OBSCipher

+

Yes

+

Explanation:

+

OBS cipher generated by calling cipher_generator.new()

+

Value range:

+

A value generated by calling cipher_generator.new(). cipher_generator is the cipher_generator parameter set for CryptoClient initialization.

+

Example: cipher = ctr_client.cipher_generator.new(""). ctr_client is the encryption client.

+

Default value:

+

None

+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_1300.html b/docs/obs_3rd_party/python_sdk/obs_22_1300.html new file mode 100644 index 000000000..a391fffda --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_1300.html @@ -0,0 +1,19 @@ + + +

Other APIs (SDK for Python)

+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_1301.html b/docs/obs_3rd_party/python_sdk/obs_22_1301.html new file mode 100644 index 000000000..f7bdc0f27 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_1301.html @@ -0,0 +1,346 @@ + + +

Creating a Signed URL (SDK for Python)

+

Function

This API creates a URL whose Query parameters are carried with authentication information by specifying the AK and SK, HTTP method, and request parameters. You can provide other users with this URL for temporary access. When generating a URL, you need to specify the validity period of the URL to restrict the access duration of visitors.

+

If you want to grant other users the permission to perform other operations on buckets or objects (for example, upload or download objects), generate a URL with the corresponding request (for example, to upload an object using the URL that generates the PUT request) and provide the URL for other users.

+
+

Restrictions

+ +
+

Method

ObsClient.createSignedUrl(method, bucketName, objectKey, specialParam, expires, headers, queryParams)
+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

method

+

str

+

Yes

+

Explanation:

+

HTTP methods

+

Value range:

+
  • GET
  • POST
  • PUT
  • DELETE
  • HEAD
+

Default value:

+

None

+

bucketName

+

str

+

No

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

str

+

No

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

specialParam

+

str

+

No

+

Explanation:

+

Special operator, which indicates the sub-resource to be operated

+

Value range:

+
  • versions
  • uploads
  • location
  • storageinfo
  • quota
  • storagePolicy
  • acl
  • append
  • logging
  • policy
  • lifecycle
  • website
  • versioning
  • cors
  • notification
  • tagging
  • delete
  • restore
+

Default value:

+

None

+

expires

+

int

+

No

+

Explanation:

+

Expiration time of the signed URL

+

Value range:

+
  • The value of this parameter for temporary credentials ranges from 0 to 86400, in seconds.
  • The value of this parameter for permanent keys ranges from 0 to 630720000, in seconds.
+

Default value:

+

300

+

headers

+

dict

+

No

+

Explanation:

+

Headers in the request

+

Default value:

+

None

+

queryParams

+

dict

+

No

+

Explanation:

+

Query parameters in the request

+

Default value:

+

None

+
+
+

If a CORS or signature mismatch error occurs, refer to the following steps to troubleshoot the issue:

+
  1. If CORS is not configured, you need to configure CORS rules on OBS Console.
  2. If the signatures do not match, check whether signature parameters are correct. For example, during an object upload, the backend uses Content-Type to calculate the signature and generate an authorized URL, but if Content-Type is not set or is set to an incorrect value when the frontend uses the authorized URL, a CORS error occurs. To avoid this issue, ensure that Content-Type fields at both the frontend and backend are kept consistent.
+
+
+

Responses

+
+ + + + + + + + + + + + + +
Table 2 List of returned results

Parameter

+

Type

+

Description

+

signedUrl

+

str

+

Explanation:

+

Signed URL

+

Default value:

+

None

+

actualSignedRequestHeaders

+

dict

+

Explanation:

+

Actual headers in the request initiated by using the signed URL

+

Default value:

+

None

+
+
+
+

Code Examples

This example creates temporary signed URLs.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
from obs import ObsClient
+import os
+import traceback
+import base64
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    # Create a signed URL for creating a bucket.
+    res1 = obsClient.createSignedUrl(method='PUT', bucketName='bucketname', expires=3600)
+    print('signedUrl:', res1.signedUrl)
+    print('actualSignedRequestHeaders:', res1.actualSignedRequestHeaders)
+
+    # Create a signed URL for uploading an object.
+    res2 = obsClient.createSignedUrl(method='PUT', bucketName='bucketname', objectKey='objectkey', expires=3600,
+                                     headers={'Content-Type': 'text/plain'})
+    print('signedUrl:', res2.signedUrl)
+    print('actualSignedRequestHeaders:', res2.actualSignedRequestHeaders)
+
+    # Create a signed URL for setting an object ACL.
+    res3 = obsClient.createSignedUrl(method='PUT', bucketName='bucketname', objectKey='objectkey', specialParam='acl',
+                                     expires=3600, headers={'x-obs-acl': 'private'})
+    print('signedUrl:', res3.signedUrl)
+    print('actualSignedRequestHeaders:', res3.actualSignedRequestHeaders)
+
+    # Create a signed URL for downloading an object.
+    res4 = obsClient.createSignedUrl(method='GET', bucketName='bucketname', objectKey='objectkey', expires=3600)
+    print('signedUrl:', res4.signedUrl)
+    print('actualSignedRequestHeaders:', res4.actualSignedRequestHeaders)
+
+    # Create a signed URL for deleting an object.
+    res5 = obsClient.createSignedUrl(method='DELETE', bucketName='bucketname', objectKey='objectkey', expires=3600)
+    print('signedUrl:', res5.signedUrl)
+    print('actualSignedRequestHeaders:', res5.actualSignedRequestHeaders)
+
+    # Create a signed URL for deleting a bucket.
+    res6 = obsClient.createSignedUrl(method='DELETE', bucketName='bucketname', expires=3600)
+    print('signedUrl:', res6.signedUrl)
+    print('actualSignedRequestHeaders:', res6.actualSignedRequestHeaders)
+
+    # Create a signed URL for initiating a multipart task.
+    res7 = obsClient.createSignedUrl(method='POST', bucketName='bucketname', objectKey='objectkey',
+                                     specialParam='uploads', expires=3600)
+    print('signedUrl:', res7.signedUrl)
+    print('actualSignedRequestHeaders:', res7.actualSignedRequestHeaders)
+
+    # Create a signed URL for uploading a part.
+    res8 = obsClient.createSignedUrl(method='PUT', bucketName='bucketname', objectKey='objectkey', expires=3600,
+                                     queryParams={'partNumber': '1', 'uploadId': '00000*****'})
+    print('signedUrl:', res8.signedUrl)
+    print('actualSignedRequestHeaders:', res8.actualSignedRequestHeaders)
+
+    # Create a signed URL for assembling parts.
+    res9 = obsClient.createSignedUrl(method='POST', bucketName='bucketname', objectKey='objectkey', expires=3600,
+                                     queryParams={'uploadId': '00000*****'})
+    print('signedUrl:', res9.signedUrl)
+    print('actualSignedRequestHeaders:', res9.actualSignedRequestHeaders)
+
+    # Create a signed URL for image persistency.
+    # Name of the bucket that stores the source object
+    bucketName = 'originBucketName'; 
+    # Source object name before the processing
+    objectKey = 'test.png';
+
+    # Name of the object after processing
+    targetObjectName ="save.png"
+    # (Optional) Name of the bucket that stores the new object
+    targetBucketName ="saveBucketName"
+    queryParams={}
+    queryParams["x-image-process"]="image/resize,w_100"
+    queryParams["x-image-save-object"]=base64.b64encode(targetObjectName .encode("utf-8")).decode()
+    # Optional parameter
+    queryParams["x-image-save-bucket"]=base64.b64encode(targetBucketName .encode("utf-8")).decode()
+
+    res10 = obsClient.createSignedUrl(method='GET', bucketName=bucketName, objectKey=objectKey, queryParams=queryParams, expires=3600)
+    print('signedUrl:', res10.signedUrl)
+    print('actualSignedRequestHeaders:', res10.actualSignedRequestHeaders)
+except:
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_1302.html b/docs/obs_3rd_party/python_sdk/obs_22_1302.html new file mode 100644 index 000000000..0ca664197 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_1302.html @@ -0,0 +1,202 @@ + + +

Generating Authentication Parameters for Browser-Based Uploads (SDK for Python)

+

Function

This API generates parameters for authentication. The parameters can be used to perform a browser-based upload through POST operations.

+

There are two request parameters generated for authentication:

+
  • policy, which corresponds to the policy parameter in the form.
  • signature, which corresponds to the signature parameter in the form.
+
+
+

Restrictions

+
+

Method

ObsClient.createPostSignature(bucketName, objectKey, expires, formParams)
+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

str

+

No

+

Explanation:

+

Bucket name

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

str

+

No

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

expires

+

int

+

No

+

Explanation:

+

Expiration time of authentication for a browser-based upload

+

Value range:

+

An integer greater than or equal to 0, in seconds

+

Default value:

+

300

+

formParams

+

dict

+

No

+

Explanation:

+

Parameters of browser-based uploads, not including key, policy, and signature.

+

Value range:

+
  • acl
  • cache-control
  • content-type
  • content-disposition
  • content-encoding
  • expires
+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + +
Table 2 List of returned results

Parameter

+

Type

+

Description

+

originPolicy

+

str

+

Explanation:

+

policy not encoded by Base64. This parameter can only be used for verification.

+

Example: {"expiration":"2023-09-12T12:52:59Z","conditions":[{"content-type":"text/plain"},{"bucket":"examplebucket"},{"key":"example/objectname"},]}"

+

Default value:

+

None

+

policy

+

str

+

Explanation:

+

Base64-encoded value of policy in the form

+

Example: eyJleHBpcmF0aW9uIjoiMjAyMy0wOS0xMlQxMjo1Mjo1OVoiLCJjb25kaXRpb25zIjpbeyJjb250ZW50LXR5cGUiOiJ0ZXh0L3BsYWluIn0seyJidWNrZXQiOiJleGFtcGxlYnVja2V0In0seyJrZXkiOiJleGFtcGxlL29iamVjdG5hbWUifSxdfQ==

+

Default value:

+

None

+

signature

+

str

+

Explanation:

+

signature in the form

+

Example: g0jQr4v9VWd1Q2FOFDG6LGfV9Cw=

+

Default value:

+

None

+
+
+
+

Code Examples

This example generates authentication parameters policy and signature for a browser-based upload.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName = "examplebucket"
+    objectKey = "objectname"
+    # Configure the validity period (in seconds) for a browser-based upload request. 3600 is used as an example.
+    expires = 3600
+    # Specify parameters for a browser-based upload except key, policy, and signature. In this example, x-obs-acl is set to private and content-type is set to text/plain.
+    formParams = {'x-obs-acl': 'private', 'content-type': 'text/plain'}
+    # Create parameters for a browser-based upload.
+    resp = obsClient.createPostSignature(bucketName, objectKey, expires, formParams)
+
+    print('originPolicy:', resp.originPolicy)
+    print('policy:', resp.policy)
+    print('signature:', resp.signature)
+except:
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_1303.html b/docs/obs_3rd_party/python_sdk/obs_22_1303.html new file mode 100644 index 000000000..a26b9ad0c --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_1303.html @@ -0,0 +1,494 @@ + + +

Server-Side Encryption (SDK for Python)

+

Function

This API configures server-side encryption for objects, so that they will be encrypted or decrypted when you upload them to or download them from a bucket.

+

The encryption and decryption happen on the server side.

+

There are different encryption methods for you to choose from. Available encryption methods include server-side encryption with KMS-managed keys (SSE-KMS) and server-side encryption with customer-provided keys (SSE-C). Both of the two methods use the AES-256 algorithm.

+

With SSE-KMS, OBS uses the keys provided by KMS for server-side encryption.

+

With SSE-C, OBS uses the keys and MD5 values provided by customers for server-side encryption.

+

When server-side encryption is used, the returned ETag value is not the object's MD5 value. OBS will verify the object's MD5 value as long as the upload request includes the Content-MD5 header, no matter whether server-side encryption is used or not.

+
+

Restrictions

+
+

Method

ObsClient.putFile(bucketName, objectKey, file_path, metadata, headers, extensionHeaders)
+
+

Supported APIs

The following table lists APIs related to server-side encryption:

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Method in OBS SDK for Python

+

Description

+

Supported Encryption Method

+

ObsClient.putContent

+

Sets the encryption algorithm and key during object upload to enable server-side encryption.

+

SSE-KMS

+

SSE-C

+

ObsClient.putFile

+

Sets the encryption algorithm and key during file upload to enable server-side encryption.

+

SSE-KMS

+

SSE-C

+

ObsClient.getObject

+

Sets the decryption algorithm and key during object download to decrypt the object.

+

SSE-C

+

ObsClient.copyObject

+
  1. Sets the decryption algorithm and key for decrypting the source object during object copy.
  2. Sets the encryption algorithm and key during object copy to enable the encryption algorithm for the target object.
+

SSE-KMS

+

SSE-C

+

ObsClient.getObjectMetadata

+

Sets the decryption algorithm and key when obtaining the object metadata to decrypt the object.

+

SSE-C

+

ObsClient.initiateMultipartUpload

+

Sets the encryption algorithm and key when initializing a multipart upload task to enable server-side encryption for the final object generated.

+

SSE-KMS

+

SSE-C

+

ObsClient.uploadPart

+

Sets the encryption algorithm and key during multipart upload to enable server-side encryption for parts.

+

SSE-C

+

ObsClient.copyPart

+
  1. Sets the decryption algorithm and key for decrypting the source object during multipart copy.
  2. Sets the encryption algorithm and key during part copy to enable the encryption for the target part.
+

SSE-C

+
+
+
+

Responses

+
+ + + + + + + +
Table 1 List of returned results

Type

+

Description

+

GetResult

+

Explanation:

+

SDK common results

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 GetResult

Parameter

+

Type

+

Description

+

status

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

reason

+

str

+

Explanation:

+

Reason description.

+

Default value:

+

None

+

errorCode

+

str

+

Explanation:

+

Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

errorMessage

+

str

+

Explanation:

+

Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

requestId

+

str

+

Explanation:

+

Request ID returned by the OBS server

+

Default value:

+

None

+

indicator

+

str

+

Explanation:

+

Error indicator returned by the OBS server.

+

Default value:

+

None

+

hostId

+

str

+

Explanation:

+

Requested server ID. If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

resource

+

str

+

Explanation:

+

Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank.

+

Default value:

+

None

+

header

+

list

+

Explanation:

+

Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header.

+

Default value:

+

None

+

body

+

object

+

Explanation:

+

Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python).

+

Default value:

+

None

+
+
+
+

Code Examples

This example uploads and downloads an encrypted file using SSE-KMS.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
from obs import ObsClient
+from obs import PutObjectHeader, GetObjectHeader
+from obs import SseKmsHeader
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    put_headers = PutObjectHeader()
+    # Specify the SSE-KMS encryption header for the object upload request.
+    put_headers.sseHeader = SseKmsHeader.getInstance()
+
+    bucketName = "examplebucket"
+    # Specify an object name (the name displayed after the file is uploaded to the bucket).
+    objectKey = "objectname"
+    # Specify the full path of the file or folder to be uploaded, for example, aa/bb.txt or aa/.
+    file_path = 'localfile'
+    # Upload the object.
+    resp = obsClient.putFile(bucketName, objectKey, file_path, headers=put_headers)
+
+
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Put File Succeeded')
+        print('requestId:', resp.requestId)
+    else:
+        print('Put File Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+
+# ---------------------------------------------------------------------------------------------------------------------
+
+    get_headers = GetObjectHeader()
+    # Specify the SSE-KMS decryption header for the object download request.
+    get_headers.sseHeader = SseKmsHeader.getInstance()
+
+    bucketName = "examplebucket"
+    objectKey = "objectname"
+    # Specify the full path (localfile as an example) to which objects are downloaded. The full path contains the local file name.
+    downloadPath = 'localfile'
+    # Download the object.
+    resp2 = obsClient.getObject(bucketName, objectKey, downloadPath, headers=get_headers)
+
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp2.status < 300:
+        print('Get Object Succeeded')
+        print('requestId:', resp2.requestId)
+    else:
+        print('Get Object Failed')
+        print('requestId:', resp2.requestId)
+        print('errorCode:', resp2.errorCode)
+        print('errorMessage:', resp2.errorMessage)
+except:
+    print(traceback.format_exc())
+
+
+

+

This example uploads and downloads an encrypted file using SSE-C.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
from obs import ObsClient
+from obs import PutObjectHeader, GetObjectHeader
+from obs import SseCHeader
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    put_headers = PutObjectHeader()
+    # Specify the SSE-C encryption header for the object upload request. encryption indicates the encryption method and key indicates the SSE-C key generated by the AES 256 algorithm.
+    put_headers.sseHeader = SseCHeader(encryption='AES256', key='your sse-c key generated by AES-256 algorithm')
+
+    bucketName = "examplebucket"
+    # Specify an object name (the name displayed after the file is uploaded to the bucket).
+    objectKey = "objectname"
+    # Specify the full path of the file or folder to be uploaded, for example, aa/bb.txt or aa/.
+    file_path = 'localfile'
+    # Upload the object.
+    resp = obsClient.putFile(bucketName, objectKey, file_path, headers=put_headers)
+
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Put File Succeeded')
+        print('requestId:', resp.requestId)
+    else:
+        print('Put File Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+
+# ---------------------------------------------------------------------------------------------------------------------
+
+    get_headers = GetObjectHeader()
+    # Specify the SSE-C decryption header for an object download request. The key used here must be the one used for uploading the object.
+    get_headers.sseHeader = SseCHeader(encryption='AES256', key='your sse-c key generated by AES-256 algorithm')
+
+    bucketName = "examplebucket"
+    objectKey = "objectname"
+    # Specify the full path (localfile as an example) to which objects are downloaded. The full path contains the local file name.
+    downloadPath = 'localfile'
+    # Download the object.
+    resp2 = obsClient.getObject(bucketName, objectKey, downloadPath, headers=get_headers)
+
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp2.status < 300:
+        print('Get Object Succeeded')
+        print('requestId:', resp2.requestId)
+    else:
+        print('Get Object Failed')
+        print('requestId:', resp2.requestId)
+        print('errorCode:', resp2.errorCode)
+        print('errorMessage:', resp2.errorMessage)
+except:
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_1304.html b/docs/obs_3rd_party/python_sdk/obs_22_1304.html new file mode 100644 index 000000000..1249f5ebf --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_1304.html @@ -0,0 +1,480 @@ + + +

Static Website Hosting (SDK for Python)

+

Function

This API uploads the files of the static website to your bucket in OBS as objects and configures the public-read permission on the files, and then configures the static website hosting mode for your bucket to host your static websites in OBS. After this, when third-party users access your websites, they actually access the objects in your bucket in OBS. When using static website hosting, you can configure request redirection to redirect specific or all requests.

+

+
+

Restrictions

+
+

Uploading a Website File to a Bucket

1. Upload the website files to your bucket in OBS as objects and set the MIME type for the objects.

+

2. Set the ACL for the objects to public-read.

+

3. Access the objects using a browser.

+

+

This example uploads an HTML website file to a bucket and grants the public read permission for the object to implement static website hosting.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
from obs import ObsClient
+import os
+from obs import PutObjectHeader
+from obs import HeadPermission
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName = 'bucketname'
+    # Specify a website file name.
+    objectKey = 'test.html'
+# Specify the path of a local HTML website file.
+    file_path = 'localfile.html'
+    headers = PutObjectHeader()
+    # Specify the MIME type for the object.
+    headers.contentType = 'text/html'
+
+    # Upload the object.
+    resp = obsClient.putFile(bucketName, objectKey, file_path, headers=headers)
+
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Put File Succeeded')
+        print('requestId:', resp.requestId)
+       # Set the object ACL to public-read.
+        resp2 = obsClient.setObjectAcl(bucketName, objectKey, aclControl=HeadPermission.PUBLIC_READ)
+        if resp2.status < 300:
+            print('Set Object Acl Succeeded')
+            print('requestId:', resp2.requestId)
+        else:
+            print('Set Object Acl Failed')
+            print('requestId:', resp2.requestId)
+            print('errorCode:', resp2.errorCode)
+            print('errorMessage:', resp2.errorMessage)
+    else:
+        print('Put File Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Put File Failed')
+    print(traceback.format_exc())
+
+
+

You can use https://bucketname.your-endpoint/test.html in a browser to access files hosted using the sample code.

+
+
+

Configuring Static Website Hosting

This example configures static website hosting for bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
from obs import ObsClient
+from obs import WebsiteConfiguration
+from obs import IndexDocument
+from obs import ErrorDocument
+from obs import RoutingRule
+from obs import Condition
+from obs import Redirect
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    # Specify an error page when a 4XX error occurs.
+    errorDocument = ErrorDocument(key='error.html')
+    # Specify a default page.
+    indexDocument = IndexDocument(suffix='index.html')
+    # Specify a rule for redirecting requests to NotFound.html if the status code is 404.
+    routingRule1 = RoutingRule(condition=Condition(httpErrorCodeReturnedEquals=404),
+                               redirect=Redirect(protocol='http', replaceKeyWith='NotFound.html'))
+    # Configure the redirection rules in list format. Multiple rules can be configured.
+    routingRules = [routingRule1]
+    bucketName = "examplebucket"
+    # Configure static website hosting for the bucket.
+    resp = obsClient.setBucketWebsite(bucketName,
+                                      WebsiteConfiguration(errorDocument=errorDocument, indexDocument=indexDocument,
+                                                           routingRules=routingRules))
+
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Set Bucket Website Succeeded')
+        print('requestId:', resp.requestId)
+    else:
+        print('Set Bucket Website Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Set Bucket Website Failed')
+    print(traceback.format_exc())
+
+
+

+

This example configures redirection for all requests.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
from obs import ObsClient
+import os
+import traceback
+from obs import WebsiteConfiguration
+from obs import RedirectAllRequestTo
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName = 'bucketname'
+    # Configure redirection for all requests.
+    resp = obsClient.setBucketWebsite(bucketName,
+                                       WebsiteConfiguration(
+                                           redirectAllRequestTo=RedirectAllRequestTo(hostName='www.example.com',
+                                                                                     protocol='http')))
+    if resp.status < 300:
+        print('Set Bucket Website Succeeded')
+        print('requestId:', resp.requestId)
+    else:
+        print('Set Bucket Website Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Set Bucket Website Failed')
+    print(traceback.format_exc())
+
+
+
+

Viewing Static Website Hosting

This example returns the static website hosting configuration of bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName="examplebucket"
+    # Obtain the static website configuration of the bucket.
+    resp = obsClient.getBucketWebsite(bucketName)
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Get Bucket Website Succeeded')
+        print('requestId:', resp.requestId)
+        if resp.body.redirectAllRequestTo:
+            print('redirectAllRequestTo.hostName:', resp.body.redirectAllRequestTo.hostName,
+                  ',redirectAllRequestTo.protocol:', resp.body.redirectAllRequestTo.protocol)
+        if resp.body.indexDocument:
+            print('indexDocument.suffix:', resp.body.indexDocument.suffix)
+        if resp.body.errorDocument:
+            print('errorDocument.key:', resp.body.errorDocument.key)
+        if resp.body.routingRules:
+            index = 1
+            for rout in resp.body.routingRules:
+                print('routingRule[', index, ']:')
+                index += 1
+                print('condition.keyPrefixEquals:', rout.condition.keyPrefixEquals,
+                      ',condition.httpErrorCodeReturnedEquals:', rout.condition.httpErrorCodeReturnedEquals)
+                print('redirect.protocol:', rout.redirect.protocol, ',redirect.hostName:', rout.redirect.hostName,
+                      ',redirect.replaceKeyPrefixWith:', rout.redirect.replaceKeyPrefixWith,
+                      ',redirect.replaceKeyWith:', rout.redirect.replaceKeyWith, ',redirect.httpRedirectCode:',
+                      rout.redirect.httpRedirectCode)
+    else:
+        print('Get Bucket Website Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Get Bucket Website Failed')
+    print(traceback.format_exc())
+
+
+
+

Deleting Static Website Hosting

This example deletes the static website hosting configuration of bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName = "examplebucket"
+    # Delete the static website hosting configuration of the bucket.
+    resp = obsClient.deleteBucketWebsite(bucketName)
+
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Delete Bucket Website Succeeded')
+        print('requestId:', resp.requestId)
+    else:
+        print('Delete Bucket Website Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Delete Bucket Website Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_1305.html b/docs/obs_3rd_party/python_sdk/obs_22_1305.html new file mode 100644 index 000000000..fe743c60b --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_1305.html @@ -0,0 +1,285 @@ + + +

User-defined Header (SDK for Python)

+

Function

When calling an API, you can configure user-defined headers to meet specific needs. The SDK will automatically calculate the signature for the specified headers if needed.

+

Method:

+

You can add the specified headers in extensionHeaders in the dictionary format.

+
+

Code Examples

This example configures user-defined headers to use the single-connection bandwidth throttling function for downloading object objectname from bucket examplebucket at a limited rate.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName = "examplebucket"
+    objectKey = "objectname"
+    # Configure the download rate limit by specifying x-obs-traffic-limit, in bits. The value range is from 819200 (100 KB) to 838860800 (100 MB). 819200 is used as an example.
+    extensionHeaders = {'x-obs-traffic-limit': 819200}
+    # Specify the full path (localfile as an example) to which objects are downloaded. The full path contains the local file name.
+    downloadPath = 'localfile'
+    # Download the object at a limited rate.
+    resp = obsClient.getObject(bucketName, objectKey, downloadPath, extensionHeaders=extensionHeaders)
+
+    # If status code 2xx is returned, the API was called successfully. Otherwise, the call failed.
+    if resp.status < 300:
+        print('Get Object Succeeded')
+        print('requestId:', resp.requestId)
+        print('url:', resp.body.url)
+    else:
+        print('Get Object Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Get Object Failed')
+    print(traceback.format_exc())
+
+
+

This example configures a user-defined header to implement the upload callback.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
from obs import ObsClient
+import os
+import traceback
+from urllib.parse import quote
+import base64
+import json
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    # Specify a protocol.
+    protocol = 'http://'
+
+    # Specify the callback address. If the URL contains any special characters or full-width characters, they must be URL-encoded using quote(str).
+    callbackUrl1 = protocol + quote("www.example.com/callback1")
+    callbackUrl2 = protocol + quote ("www.example.com/full-width-characters?key=object-name-in-full-width-characters")
+    # (Optional) Specify the value of the host header carried in the callback request. If this parameter is not specified, the value of host parsed from callbackUrl is used.
+    callbackHost = 'www.example.com'
+    # Specify the body of the callback request.
+    callbackBody = 'key=$(key)&override=$(override)&size=$(size)&bucket=$(bucket)&etag=$(etag)'
+    # Configure the upload callback.
+    callBackPolicy = {"callbackBody": callbackBody, "callbackUrl": callbackUrl1 + ';' + callbackUrl2,
+                      "callbackHost": callbackHost}
+
+    # Configure the custom headers by specifying extensionHeaders. The input parameters are in the dictionary format.
+    # Convert callBackPolicy to a JSON string and then to  binary using json.dumps().encode(). Then, encode the results using Base64 (base64.b64encode()) and convert the encoded data which is in binary mode to a string using str(b'str', "utf-8").
+    extensionHeaders = {'x-obs-callback': str(base64.b64encode(json.dumps(callBackPolicy).encode()), "utf-8")}
+
+    bucketName = 'your-bucketName'
+    objectKey = 'example.txt'
+    content = 'Hello OBS'
+    # Upload the text and perform the upload callback.
+    resp = obsClient.putContent(bucketName, objectKey, content, extensionHeaders=extensionHeaders)
+
+    # If status code 2xx is returned, the API was called successfully. Otherwise, the call failed.
+    if resp.status < 300:
+        print('Put Content Succeeded')
+        print('requestId:', resp.requestId)
+        print('etag:', resp.body.etag)
+    else:
+        print('Put Content Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Put Content Failed')
+    print(traceback.format_exc())
+
+
+
This example changes the expiration time of an object using a user-defined header.
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
from obs import ObsClient
+import os
+import traceback
+
+# Obtain an AK and SK pair using environment variables or import the AK and SK pair in other ways. Using hard coding may result in leakage.
+# Obtain an AK and SK pair on the management console.
+ak = os.getenv("AccessKeyID")
+sk = os.getenv("SecretAccessKey")
+# (Optional) If you use a temporary AK and SK pair and a security token to access OBS, obtain them from environment variables.
+# security_token = os.getenv("SecurityToken")
+# Set server to the endpoint of the region where the bucket is located.
+server = "https://your-endpoint"
+
+# Create an obsClient instance.
+# If you use a temporary AK and SK pair and a security token to access OBS, you must specify security_token when creating an instance.
+obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName = "examplebucket"
+    objectKey = "objectname"
+    # x-obs-expires indicates how many days after the last modification the object expires. This example configures 3 days.
+    extensionHeaders = {'x-obs-expires': 3}
+    # Configure the object metadata.
+    resp = obsClient.setObjectMetadata(bucketName, objectKey, extensionHeaders=extensionHeaders)
+
+    # If status code 2xx is returned, the API was called successfully. Otherwise, the call failed.
+    if resp.status < 300:
+        print('Set Object Metadata Succeeded')
+        print('requestId:', resp.requestId)
+    else:
+        print('Set Object Metadata Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print('Set Object Metadata Failed')
+    print(traceback.format_exc())
+
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_1500.html b/docs/obs_3rd_party/python_sdk/obs_22_1500.html new file mode 100644 index 000000000..bec1afc19 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_1500.html @@ -0,0 +1,15 @@ + + +

Troubleshooting (SDK for Python)

+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_1501.html b/docs/obs_3rd_party/python_sdk/obs_22_1501.html new file mode 100644 index 000000000..dfd7c264f --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_1501.html @@ -0,0 +1,115 @@ + + +

HTTP Status Codes (SDK for Python)

+

The OBS server complies with the HTTP standard. After an API is called, the OBS server returns a standard HTTP status code. The following tables list the categories of HTTP status codes and the common HTTP status codes in OBS.

+ +
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_1502.html b/docs/obs_3rd_party/python_sdk/obs_22_1502.html new file mode 100644 index 000000000..c57124cad --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_1502.html @@ -0,0 +1,729 @@ + + +

OBS Server-Side Error Codes (SDK for Python)

+

If the OBS server encounters an error when processing a request, a response containing the error code and error description is returned.

+

The following table lists details about each error and its HTTP status code.

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

HTTP Status Code

+

Error Code

+

Error Message

+

Solution

+

301 Moved Permanently

+

PermanentRedirect

+

The requested bucket can be accessed only through the specified address. Send subsequent requests to the address.

+

Send the request to the returned redirection address.

+

301 Moved Permanently

+

WebsiteRedirect

+

The website request lacks bucketName.

+

Put the bucket name in the request and try again.

+

307 Moved Temporarily

+

TemporaryRedirect

+

Temporary redirection. If the DNS is updated, the request is redirected to the bucket.

+

The system automatically redirects the request or sends the request to the redirection address.

+

400 Bad Request

+

BadDigest

+

The specified value of Content-MD5 does not match the value received by OBS.

+

Check whether the MD5 value carried in the header is the same as that calculated by the message body.

+

400 Bad Request

+

BadDomainName

+

Invalid domain name.

+

Use a valid domain name.

+

400 Bad Request

+

BadRequest

+

Invalid request parameter.

+

Modify the parameter according to the error details returned in the message body.

+

400 Bad Request

+

CustomDomainAreadyExist

+

The configured domain already exists.

+

It has been configured and does not need to be configured again.

+

400 Bad Request

+

CustomDomainNotExist

+

Delete the domain that does not exist.

+

It is not configured or has been deleted. You do not need to delete it.

+

400 Bad Request

+

EntityTooLarge

+

The size of the object uploaded using the POST method exceeds the upper limit.

+

Modify the conditions specified in the policy when posting the object or reduce the object size.

+

400 Bad Request

+

EntityTooSmall

+

The size of the object uploaded using the POST method does not reach the lower limit.

+

Modify the conditions specified in the policy when posting the object or increase the object size.

+

400 Bad Request

+

IllegalLocationConstraintException

+

A request without Location is sent for creating a bucket in a non-default region.

+

Send the bucket creation request to the default region, or send the request with the Location of the non-default region.

+

400 Bad Request

+

IncompleteBody

+

No complete request body is received due to network or other problems.

+

Upload the object again.

+

400 Bad Request

+

IncorrectNumberOfFilesInPost Request

+

Each POST request must contain one file to be uploaded.

+

Carry a file to be uploaded.

+

400 Bad Request

+

InvalidArgument

+

Invalid parameter.

+

Modify the parameter according to the error details returned in the message body.

+

400 Bad Request

+

InvalidBucket

+

The bucket to be accessed does not exist.

+

Try another bucket name.

+

400 Bad Request

+

InvalidBucketName

+

The bucket name specified in the request is invalid, which may have exceeded the maximum length, or contain special characters that are not allowed.

+

Try another bucket name.

+

400 Bad Request

+

InvalidEncryptionAlgorithmError

+

Incorrect encryption algorithm. The object cannot be decrypted due to incorrect encryption header carried when downloading the SSE-C encrypted object.

+

Carry the correct encryption header when downloading the object.

+

400 Bad Request

+

InvalidLocationConstraint

+

The specified Location in the bucket creation request is invalid or does not exist.

+

Correct the Location in the bucket creation request.

+

400 Bad Request

+

InvalidPart

+

One or more specified parts are not found. The parts may not be uploaded or the specified entity tags (ETags) do not match the parts' ETags.

+

Specify the correct parts and entity tags.

+

400 Bad Request

+

InvalidPartOrder

+

Parts are not listed in ascending order by part number.

+

Sort the parts in ascending order and merge them again.

+

400 Bad Request

+

InvalidPolicyDocument

+

The content of the form does not meet the conditions specified in the policy document.

+

Modify the policy in the constructed form according to the error details in the message body and try again.

+

400 Bad Request

+

InvalidRedirectLocation

+

Invalid redirect location.

+

Specify the correct IP address.

+

400 Bad Request

+

InvalidRequest

+

Invalid request.

+

Modify the parameter according to the error details returned in the message body.

+

400 Bad Request

+

InvalidRequestBody

+

The request body is invalid. The request requires a message body but no message body is uploaded.

+

Upload the message body in the correct format.

+

400 Bad Request

+

InvalidTargetBucketForLogging

+

The delivery group has no ACL permission for the target bucket.

+

Configure the target bucket ACL and try again.

+

400 Bad Request

+

KeyTooLongError

+

The provided key is too long.

+

Use a shorter key.

+

400 Bad Request

+

KMS.DisabledException

+

The master key is disabled in the SSE-KMS mode.

+

Replace the key and try again, or contact the technical support.

+

400 Bad Request

+

KMS.NotFoundException

+

The customer master key (CMK) does not exist in SSE-KMS mode.

+

Retry with the correct master key.

+

400 Bad Request

+

MalformedACLError

+

The provided XML file has syntax errors or does not meet the format requirements.

+

Use the correct XML format to retry.

+

400 Bad Request

+

MalformedError

+

The XML format in the request is incorrect.

+

Use the correct XML format to retry.

+

400 Bad Request

+

MalformedLoggingStatus

+

The XML format of Logging is incorrect.

+

Use the correct XML format to retry.

+

400 Bad Request

+

MalformedPolicy

+

The bucket policy does not pass.

+

Modify the bucket policy according to the error details returned in the message body.

+

400 Bad Request

+

MalformedQuotaError

+

The Quota XML format is incorrect.

+

Use the correct XML format to retry.

+

400 Bad Request

+

MalformedXML

+

An XML file of a configuration item is in incorrect format.

+

Use the correct XML format to retry.

+

400 Bad Request

+

MaxMessageLengthExceeded

+

Copying an object does not require a message body in the request.

+

Remove the message body and retry.

+

400 Bad Request

+

MetadataTooLarge

+

The size of the metadata header has exceeded the upper limit.

+

Reduce the size of the metadata header.

+

400 Bad Request

+

MissingRegion

+

The region information is missing in the request, and the default region is required in the system.

+

Carry the region information in the request.

+

400 Bad Request

+

MissingRequestBodyError

+

This error code is returned after you send an empty XML file.

+

Provide the correct XML file.

+

400 Bad Request

+

MissingRequiredHeader

+

A required header is missing in the request.

+

Provide the required header.

+

400 Bad Request

+

MissingSecurityHeader

+

A required header is missing in the request.

+

Provide the required header.

+

400 Bad Request

+

TooManyBuckets

+

You have attempted to create more buckets than allowed.

+

Delete some buckets and try again.

+

400 Bad Request

+

TooManyCustomDomains

+

Too many user accounts are configured.

+

Delete some user accounts and try again.

+

400 Bad Request

+

TooManyWrongSignature

+

The request is rejected due to high-frequency errors.

+

Replace AK and try again.

+

400 Bad Request

+

UnexpectedContent

+

The request requires a message body which is not carried by the client, or the request does not require a message body but the client carries the message body.

+

Try again according to the instruction.

+

400 Bad Request

+

UserKeyMustBeSpecified

+

This operation is only available to special users.

+

Contact the technical support.

+

403 Forbidden

+

AccessDenied

+

Access denied, because the request does not carry a date header or the header format is incorrect.

+

Provide a correct date header in the request.

+

403 Forbidden

+

AccessForbidden

+

Insufficient permissions. No CORS rule is configured for the bucket, or the CORS rule is not matched.

+

Modify the CORS configuration of the bucket or send the matched OPTIONS request based on the CORS configuration of the bucket.

+

403 Forbidden

+

AllAccessDisabled

+

The user has no permission to perform a specific operation. The bucket name is forbidden.

+

Try another bucket name.

+

403 Forbidden

+

DeregisterUserId

+

The user has been deregistered.

+

Top up or re-register.

+

403 Forbidden

+

InArrearOrInsufficientBalance

+

The user account is in arrears, or the account balance insufficient.

+

Top up the account.

+

403 Forbidden

+

InsufficientStorageSpace

+

Insufficient storage space.

+

If the quota is exceeded, increase quota or delete some objects.

+

403 Forbidden

+

InvalidAccessKeyId

+

The access key ID provided by the customer does not exist in the system.

+

Provide correct access key ID.

+

403 Forbidden

+

RequestTimeTooSkewed

+

The request time and the server's time differ a lot.

+

Check whether the difference between the client time and the current time is too large.

+

403 Forbidden

+

SignatureDoesNotMatch

+

The provided signature in the request does not match the signature calculated by OBS.

+

Check your secret access key and signature calculation method.

+

403 Forbidden

+

Unauthorized

+

You have not been authenticated in real name.

+

Authenticate your real name and try again.

+

404 Not Found

+

NoSuchBucket

+

The bucket does not exist.

+

Create a bucket and perform the operation again.

+

404 Not Found

+

NoSuchBucketPolicy

+

No bucket policy exists.

+

Configure a bucket policy.

+

404 Not Found

+

NoSuchCORSConfiguration

+

No CORS configuration exists.

+

Configure CORS first.

+

404 Not Found

+

NoSuchCustomDomain

+

The requested user domain does not exist.

+

Set a user domain first.

+

404 Not Found

+

NoSuchKey

+

The specified key does not exist.

+

Upload the object first.

+

404 Not Found

+

NoSuchLifecycleConfiguration

+

The requested Lifecycle does not exist.

+

Configure a lifecycle rule first.

+

404 Not Found

+

NoSuchUpload

+

The specified multipart upload does not exist. The upload ID does not exist or the multipart upload has been aborted or completed.

+

Use the existing part or reinitialize the part.

+

404 Not Found

+

NoSuchVersion

+

The specified version ID does not match any existing version.

+

Use a correct version ID.

+

404 Not Found

+

NoSuchWebsiteConfiguration

+

The requested website does not exist.

+

Configure the website first.

+

405 Method Not Allowed

+

MethodNotAllowed

+

The specified method is not allowed against the requested resource.

+

The message "Specified method is not supported." is returned.

+

The method is not allowed.

+

408 Request Timeout

+

RequestTimeout

+

The socket connection to the server has no read or write operations within the timeout period.

+

Check the network and try again, or contact technical support.

+

409 Conflict

+

BucketAlreadyExists

+

The requested bucket name already exists. The bucket namespace is shared by all users of OBS. Try again with another bucket name.

+

Try another bucket name.

+

409 Conflict

+

BucketAlreadyOwnedByYou

+

Your previous request for creating the named bucket succeeded and you already own it.

+

You do not need to create the bucket again.

+

409 Conflict

+

BucketNotEmpty

+

The bucket that you tried to delete is not empty.

+

Delete the objects in the bucket and then delete the bucket.

+

409 Conflict

+

OperationAborted

+

A conflicting operation is being performed on this resource. Try again later.

+

Try again later.

+

409 Conflict

+

ServiceNotSupported

+

The request method is not supported by the server.

+

Not supported by the server. Contact technical support.

+

411 Length Required

+

MissingContentLength

+

The HTTP header Content-Length is not provided.

+

Provide the Content-Length header.

+

412 Precondition Failed

+

PreconditionFailed

+

At least one of the specified preconditions is not met.

+

Modify according to the condition prompt in the returned message body.

+

416 Client Requested Range Not Satisfiable

+

InvalidRange

+

The requested range cannot be obtained.

+

Replace the range value and try again.

+

500 Internal Server Error

+

InternalError

+

An internal error occurs. Try again later.

+

Contact the technical support.

+

501 Not Implemented

+

ServiceNotImplemented

+

The request method is not implemented by the server.

+

Not supported currently. Contact the technical support.

+

503 Service Unavailable

+

ServiceUnavailable

+

The server is overloaded or has internal errors.

+

Try again later or contact the technical support.

+

503 Service Unavailable

+

SlowDown

+

Reduce your request frequency.

+

Reduce your request frequency.

+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_1503.html b/docs/obs_3rd_party/python_sdk/obs_22_1503.html new file mode 100644 index 000000000..28c7831cf --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_1503.html @@ -0,0 +1,40 @@ + + +

Log Analysis (SDK for Python)

+

Log Configuration

OBS Python SDK provides the logging function based on the Python log library. You can call ObsClient.initLog to enable and configure logging. Sample code is as follows:

+
# Import the module.
+from obs import LogConf
+from obs import ObsClient
+
+# Create an instance of ObsClient.
+obsClient = ObsClient(
+    access_key_id=os.getenv("AccessKeyID"),
+    secret_access_key=os.getenv("SecretAccessKey"),
+    server='https://your-endpoint'
+)
+
+# Specify the path to the log configuration file and initialize logs of ObsClient.
+obsClient.initLog(LogConf('./log.conf'), 'obs_logger');
+
  • The logging function is disabled by default. You need to enable it manually.
  • The log configuration file example (log.conf) is included in the OBS Python SDK development package. Modify parameters in log.conf as needed.
+
+
+

The log module of the OBS Python SDK is thread secure but not process secure. If ObsClient is used in multi-process scenarios, you must configure an independent log path for each instance of ObsClient to prevent conflicts when multiple processes write logs concurrently.

+
+

Log Format

The SDK log format is: Log time|Process ID|Thread number|Log level|Log content. The following are example logs:

+
2017-11-06 13:46:54,936|process:6100|thread:12700|DEBUG|HTTP(s)+XML|OBS_LOGGER|__parse_xml,188|http response result:status:200,reason:OK,code:None,message:None,headers:[('id-2', 'LgOKocHfuHe0rFSUHS6LcChzcoYes0luPgqxhUfCP58xp3MZh2n4YKRPpABV8GEK'), ('connection', 'close'), ('request-id', '0001AFF8E60000015F8FDA1EA5AE04E3'), ('date', 'Mon, 06 Nov 2017 05:42:37 GMT'), ('content-type', 'application/xml')]|
+2017-11-06 13:46:54,937|process:6100|thread:12700|INFO|HTTP(s)+XML|OBS_LOGGER|doClose,349|server inform to close connection|
+2017-11-06 13:46:54,937|process:6100|thread:12700|INFO|HTTP(s)+XML|OBS_LOGGER|wrapper,59|listBuckets cost 56 ms|
+
+

Log Level

When current logs cannot be used to troubleshoot system faults, you can change the log level to obtain more information. You can obtain the most information in DEBUG logs and the least information in ERROR logs.

+

Log level description:

+ +

In the configuration file, LogFileLevel is used to specify the log level for log files, and PrintLogLevel is used to specify the log level for the console.

+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_1600.html b/docs/obs_3rd_party/python_sdk/obs_22_1600.html new file mode 100644 index 000000000..e7bfea151 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_1600.html @@ -0,0 +1,23 @@ + + +

FAQs (SDK for Python)

+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_1607.html b/docs/obs_3rd_party/python_sdk/obs_22_1607.html new file mode 100644 index 000000000..3e4841f3e --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_1607.html @@ -0,0 +1,12 @@ + + +

How Do I Make an Object Accessible to Anonymous Users? (SDK for Python)

+

To do this, perform the following steps:

+
  1. Set the object access permission to public-read by referring to Configuring an Object ACL (SDK for Python).
  2. Obtain the URL of the object by referring to How Do I Obtain an Object URL? (Python SDK) and provide it to anonymous users.
  3. An anonymous user can access the object by entering the URL on a browser.
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_1609.html b/docs/obs_3rd_party/python_sdk/obs_22_1609.html new file mode 100644 index 000000000..8b59a53e9 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_1609.html @@ -0,0 +1,15 @@ + + +

How Can I Obtain the AK and SK? (SDK for Python)

+

OBS employs access keys (AK and SK) for signature verification to ensure that only authorized accounts can access specified OBS resources. Detailed explanations of access keys are as follows:

+ +

To create an AK and SK pair, perform the following steps:

+
  1. Log in to the management console.
  2. In the upper right corner, hover your cursor over the username and choose My Credentials.
  3. On the My Credentials page, click Access Keys in the navigation pane.
  4. On the Access Keys page, click Create Access Key.

    +
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_1613.html b/docs/obs_3rd_party/python_sdk/obs_22_1613.html new file mode 100644 index 000000000..f72153908 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_1613.html @@ -0,0 +1,32 @@ + + +

How Do I Obtain an Object URL? (Python SDK)

+

After setting an ACL to grant anonymous users the read permission for an object in a bucket, you can download this object using its URL. Methods to obtain the object URL are as follows:

+

Method 1: Query by calling the API. After an object is uploaded by calling ObsClient.putContent or ObsClient.putFile, PutContentResponse is returned. You can call objectUrl to obtain the URL of the uploaded object. Sample code is as follows:

+
# Import the module.
+from obs import ObsClient
+
+# Create an instance of ObsClient.
+obsClient = ObsClient(
+    access_key_id=os.getenv("AccessKeyID"),
+    secret_access_key=os.getenv("SecretAccessKey"),
+    server='https://your-endpoint'
+)
+resp = obsClient.putContent('bucketname', 'objectname', content='Hello OBS')
+     
+if resp.status < 300:
+    print('requestId:', resp.requestId)
+    print('objectUrl:', resp.body.objectUrl)
+else:
+    print('requestId:', resp.requestId)
+    print('errorCode:', resp.errorCode)
+

Method 2: Compose the URL in the format of https://Bucket name.Domain name/Directory level/Object name.

+
  • If the object resides in the root directory of a bucket, its URL does not contain a directory level.
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_1614.html b/docs/obs_3rd_party/python_sdk/obs_22_1614.html new file mode 100644 index 000000000..7e5762875 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_1614.html @@ -0,0 +1,13 @@ + + +

How Do I Improve the Uploading Speed of Large Files over the Public Network? (SDK for Python)

+

If a file exceeds 100 MB, you are advised to upload the file using multipart upload.

+

Multipart upload refers to splitting an object into multiple parts and uploading them separately. Each part is a contiguous portion of the object's data. You can upload parts in any sequence. A part can be reloaded after an upload failure, without affecting other parts. Uploading multiple parts of an object using multiple threads concurrently can greatly improve the transmission efficiency.

+

For details about the sample code, see APIs Related to Multipart Upload (SDK for Python).

+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_1701.html b/docs/obs_3rd_party/python_sdk/obs_22_1701.html new file mode 100644 index 000000000..a26b84b57 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_1701.html @@ -0,0 +1,20 @@ + + +

Change History

+
+
+ + + + + + + +

Release Date

+

What's New

+

2025-03-30

+

This is the first official release.

+
+
+
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_1702.html b/docs/obs_3rd_party/python_sdk/obs_22_1702.html new file mode 100644 index 000000000..4041e6624 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_1702.html @@ -0,0 +1,1624 @@ + + +

What Is Content-Type (MIME)? (Python SDK)

+

Multipurpose Internet Mail Extensions (MIME) type is a standard way of describing a data type. The MIME type is passed in the Content-Type header.

+

If you do not specify Content-Type when uploading an object, the SDK determines the object type based on the suffix of the specified object name and automatically assigns a value to Content-Type.

+
+

Content-Type

Content-Type indicates the type of data to send or receive and determine the form and encoding method browsers will use to display data (mainly custom client files or media files). If no content type is specified, the type will be generated based on the file name extension. If there is no extension, the content type is application/octet-stream by default.

+
+

Common Content Types

The commonly used content types are given in the table below.

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 List of common content types

File Name Extension

+

Content-Type(Mime-Type)

+

File Name Extension

+

Content-Type(Mime-Type)

+

.* (binary stream, unknown file type)

+

application/octet-stream

+

.tif

+

image/tiff

+

.a11

+

application/x-a11

+

.acp

+

audio/x-mei-aac

+

.ai

+

application/postscript

+

.aif

+

audio/aiff

+

.aifc

+

audio/aiff

+

.aiff

+

audio/aiff

+

.anv

+

application/x-anv

+

.apk

+

application/vnd.android.package-archive

+

.asa

+

text/asa

+

.asf

+

video/x-ms-asf

+

.asp

+

text/asp

+

.asx

+

video/x-ms-asf

+

.au

+

audio/basic

+

.avi

+

video/avi

+

.awf

+

application/vnd.adobe.workflow

+

.biz

+

text/xml

+

.bmp

+

application/x-bmp

+

.bot

+

application/x-bot

+

.c4t

+

application/x-c4t

+

.c90

+

application/x-c90

+

.cal

+

application/x-cals

+

.cat

+

application/vnd.ms-pki.seccat

+

.cdf

+

application/x-netcdf

+

.cdr

+

application/x-cdr

+

.cel

+

application/x-cel

+

.cer

+

application/x-x509-ca-cert

+

.cg4

+

application/x-g4

+

.cgm

+

application/x-cgm

+

.cit

+

application/x-cit

+

.class

+

java/

+

.cml

+

text/xml

+

.cmp

+

application/x-cmp

+

.cmx

+

application/x-cmx

+

.cot

+

application/x-cot

+

.crl

+

application/pkix-crl

+

.crt

+

application/x-x509-ca-cert

+

.csi

+

application/x-csi

+

.css

+

text/css

+

.csv

+

text/csv

+

.cut

+

application/x-cut

+

.dbf

+

application/x-dbf

+

.dbm

+

application/x-dbm

+

.dbx

+

application/x-dbx

+

.dcd

+

text/xml

+

.dcx

+

application/x-dcx

+

.der

+

application/x-x509-ca-cert

+

.dgn

+

application/x-dgn

+

.dib

+

application/x-dib

+

.dll

+

application/x-msdownload

+

.doc

+

application/msword

+

.docx

+

application/vnd.openxmlformats-officedocument.wordprocessingml.document

+

.dot

+

application/msword

+

.dotx

+

application/vnd.openxmlformats-officedocument.wordprocessingml.template

+

.drw

+

application/x-drw

+

.dtd

+

text/xml

+

.dwf

+

Model/vnd.dwf

+

.dwf

+

application/x-dwf

+

.dwg

+

application/x-dwg

+

.dxb

+

application/x-dxb

+

.dxf

+

application/x-dxf

+

.edn

+

application/vnd.adobe.edn

+

.emf

+

application/x-emf

+

.eml

+

message/rfc822

+

.ent

+

text/xml

+

.epi

+

application/x-epi

+

.eps

+

application/x-ps

+

.eps

+

application/postscript

+

.etd

+

application/x-ebx

+

.exe

+

application/x-msdownload

+

.fax

+

image/fax

+

.fdf

+

application/vnd.fdf

+

.fif

+

application/fractals

+

.fo

+

text/xml

+

.frm

+

application/x-frm

+

.g4

+

application/x-g4

+

.gbr

+

application/x-gbr

+

.

+

application/x-

+

.gif

+

image/gif

+

.gl2

+

application/x-gl2

+

.gp4

+

application/x-gp4

+

.hgl

+

application/x-hgl

+

.hmr

+

application/x-hmr

+

.hpg

+

application/x-hpgl

+

.hpl

+

application/x-hpl

+

.hqx

+

application/mac-binhex40

+

.hrf

+

application/x-hrf

+

.hta

+

application/hta

+

.htc

+

text/x-component

+

.htm

+

text/html

+

.html

+

text/html

+

.htt

+

text/webviewhtml

+

.htx

+

text/html

+

.icb

+

application/x-icb

+

.ico

+

image/x-icon

+

.ico

+

application/x-ico

+

.iff

+

application/x-iff

+

.ig4

+

application/x-g4

+

.igs

+

application/x-igs

+

.iii

+

application/x-iphone

+

.img

+

application/x-img

+

.ins

+

application/x-internet-signup

+

.ipa

+

application/vnd.iphone

+

.isp

+

application/x-internet-signup

+

.IVF

+

video/x-ivf

+

.java

+

java/*

+

.jfif

+

image/jpeg

+

.jpe

+

image/jpeg

+

.jpe

+

application/x-jpe

+

.jpeg

+

image/jpeg

+

.jpg

+

image/jpeg

+

.jpg

+

application/x-jpg

+

.js

+

application/x-javascript

+

.jsp

+

text/html

+

.la1

+

audio/x-liquid-file

+

.lar

+

application/x-laplayer-reg

+

.latex

+

application/x-latex

+

.lavs

+

audio/x-liquid-secure

+

.lbm

+

application/x-lbm

+

.lmsff

+

audio/x-la-lms

+

.ls

+

application/x-javascript

+

.ltr

+

application/x-ltr

+

.m1v

+

video/x-mpeg

+

.m2v

+

video/x-mpeg

+

.m3u

+

audio/mpegurl

+

.m4e

+

video/mpeg4

+

.mac

+

application/x-mac

+

.man

+

application/x-troff-man

+

.math

+

text/xml

+

.mdb

+

application/msaccess

+

.mdb

+

application/x-mdb

+

.mfp

+

application/x-shockwave-flash

+

.mht

+

message/rfc822

+

.mhtml

+

message/rfc822

+

.mi

+

application/x-mi

+

.mid

+

audio/mid

+

.midi

+

audio/mid

+

.mil

+

application/x-mil

+

.mml

+

text/xml

+

.mnd

+

audio/x-musicnet-download

+

.mns

+

audio/x-musicnet-stream

+

.mocha

+

application/x-javascript

+

.mov

+

video/quicktime

+

.movie

+

video/x-sgi-movie

+

mp1

+

audio/mp1

+

.mp2

+

audio/mp2

+

.mp2v

+

video/mpeg

+

.mp3

+

audio/mp3

+

.mp4

+

video/mp4

+

.mpa

+

video/x-mpg

+

.mpd

+

application/vnd.ms-project

+

.mpe

+

video/x-mpeg

+

.mpeg

+

video/mpg

+

.mpg

+

video/mpg

+

.mpga

+

audio/rn-mpeg

+

.mpp

+

application/vnd.ms-project

+

.mps

+

video/x-mpeg

+

.mpt

+

application/vnd.ms-project

+

.mpv

+

video/mpg

+

.mpv2

+

video/mpeg

+

.mpw

+

application/vnd.ms-project

+

.mpx

+

application/vnd.ms-project

+

.mtx

+

text/xml

+

.mxp

+

application/x-mmxp

+

.net

+

image/pnetvue

+

.nrf

+

application/x-nrf

+

.nws

+

message/rfc822

+

.odc

+

text/x-ms-odc

+

.out

+

application/x-out

+

.p10

+

application/pkcs10

+

.p12

+

application/x-pkcs12

+

.p7b

+

application/x-pkcs7-certificates

+

.p7c

+

application/pkcs7-mime

+

.p7m

+

application/pkcs7-mime

+

.p7r

+

application/x-pkcs7-certreqresp

+

.p7s

+

application/pkcs7-signature

+

.pc5

+

application/x-pc5

+

.pci

+

application/x-pci

+

.pcl

+

application/x-pcl

+

.pcx

+

application/x-pcx

+

.pdf

+

application/pdf

+

.pdb

+

chemical/x-pdb

+

.pdx

+

application/vnd.adobe.pdx

+

.pfx

+

application/x-pkcs12

+

.pgl

+

application/x-pgl

+

.pic

+

application/x-pic

+

.pko

+

application/vnd.ms-pki.pko

+

.pl

+

application/x-perl

+

.plg

+

text/html

+

.pls

+

audio/scpls

+

.plt

+

application/x-plt

+

.png

+

image/png

+

.png

+

application/x-png

+

.pot

+

application/vnd.ms-powerpoint

+

.potx

+

application/vnd.openxmlformats-officedocument.presentationml.template

+

.ppa

+

application/vnd.ms-powerpoint

+

.ppm

+

application/x-ppm

+

.pps

+

application/vnd.ms-powerpoint

+

.ppsx

+

application/vnd.openxmlformats-officedocument.presentationml.slideshow

+

.ppt

+

application/vnd.ms-powerpoint

+

.ppt

+

application/x-ppt

+

. pptx

+

application/vnd.openxmlformats-officedocument.presentationml.presentation

+

.pr

+

application/x-pr

+

.prf

+

application/pics-rules

+

.prn

+

application/x-prn

+

.prt

+

application/x-prt

+

.ps

+

application/x-ps

+

.ps

+

application/postscript

+

.ptn

+

application/x-ptn

+

.pwz

+

application/vnd.ms-powerpoint

+

.r3t

+

text/vnd.rn-realtext3d

+

.ra

+

audio/vnd.rn-realaudio

+

.ram

+

audio/x-pn-realaudio

+

.ras

+

application/x-ras

+

.rat

+

application/rat-file

+

.rdf

+

text/xml

+

.rec

+

application/vnd.rn-recording

+

.red

+

application/x-red

+

.rgb

+

application/x-rgb

+

.rjs

+

application/vnd.rn-realsystem-rjs

+

.rjt

+

application/vnd.rn-realsystem-rjt

+

.rlc

+

application/x-rlc

+

.rle

+

application/x-rle

+

.rm

+

application/vnd.rn-realmedia

+

.rmf

+

application/vnd.adobe.rmf

+

.rmi

+

audio/mid

+

.rmj

+

application/vnd.rn-realsystem-rmj

+

.rmm

+

audio/x-pn-realaudio

+

.rmp

+

application/vnd.rn-rn_music_package

+

.rms

+

application/vnd.rn-realmedia-secure

+

.rmvb

+

application/vnd.rn-realmedia-vbr

+

.rmx

+

application/vnd.rn-realsystem-rmx

+

.rnx

+

application/vnd.rn-realplayer

+

.rp

+

image/vnd.rn-realpix

+

.rpm

+

audio/x-pn-realaudio-plugin

+

.rsml

+

application/vnd.rn-rsml

+

.rt

+

text/vnd.rn-realtext

+

.rtf

+

application/msword

+

.rtf

+

application/x-rtf

+

.rv

+

video/vnd.rn-realvideo

+

.sam

+

application/x-sam

+

.sat

+

application/x-sat

+

.sdp

+

application/sdp

+

.sdw

+

application/x-sdw

+

.sis

+

application/vnd.symbian.install

+

.sisx

+

application/vnd.symbian.install

+

.sit

+

application/x-stuffit

+

.slb

+

application/x-slb

+

.sld

+

application/x-sld

+

.sldx

+

application/vnd.openxmlformats-officedocument.presentationml.slide

+

.slk

+

drawing/x-slk

+

.smi

+

application/smil

+

.smil

+

application/smil

+

.smk

+

application/x-smk

+

.snd

+

audio/basic

+

.sol

+

text/plain

+

.sor

+

text/plain

+

.spc

+

application/x-pkcs7-certificates

+

.spl

+

application/futuresplash

+

.spp

+

text/xml

+

.ssm

+

application/streamingmedia

+

.sst

+

application/vnd.ms-pki.certstore

+

.stl

+

application/vnd.ms-pki.stl

+

.stm

+

text/html

+

.sty

+

application/x-sty

+

.svg

+

image/svg+xml

+

.swf

+

application/x-shockwave-flash

+

.tdf

+

application/x-tdf

+

.tg4

+

application/x-tg4

+

.tga

+

application/x-tga

+

.tif

+

image/tiff

+

.tif

+

application/x-tif

+

.tiff

+

image/tiff

+

.tld

+

text/xml

+

.top

+

drawing/x-top

+

.torrent

+

application/x-bittorrent

+

.tsd

+

text/xml

+

.txt

+

text/plain

+

.uin

+

application/x-icq

+

.uls

+

text/iuls

+

.vcf

+

text/x-vcard

+

.vda

+

application/x-vda

+

.vdx

+

application/vnd.visio

+

.vml

+

text/xml

+

.vpg

+

application/x-vpeg005

+

.vsd

+

application/vnd.visio

+

.vsd

+

application/x-vsd

+

.vss

+

application/vnd.visio

+

.vst

+

application/vnd.visio

+

.vst

+

application/x-vst

+

.vsw

+

application/vnd.visio

+

.vsx

+

application/vnd.visio

+

.vtx

+

application/vnd.visio

+

.vxml

+

text/xml

+

.wav

+

audio/wav

+

.wax

+

audio/x-ms-wax

+

.wb1

+

application/x-wb1

+

.wb2

+

application/x-wb2

+

.wb3

+

application/x-wb3

+

.wbmp

+

image/vnd.wap.wbmp

+

.wiz

+

application/msword

+

.wk3

+

application/x-wk3

+

.wk4

+

application/x-wk4

+

.wkq

+

application/x-wkq

+

.wks

+

application/x-wks

+

.wm

+

video/x-ms-wm

+

.wma

+

audio/x-ms-wma

+

.wmd

+

application/x-ms-wmd

+

.wmf

+

application/x-wmf

+

.wml

+

text/vnd.wap.wml

+

.wmv

+

video/x-ms-wmv

+

.wmx

+

video/x-ms-wmx

+

.wmz

+

application/x-ms-wmz

+

.wp6

+

application/x-wp6

+

.wpd

+

application/x-wpd

+

.wpg

+

application/x-wpg

+

.wpl

+

application/vnd.ms-wpl

+

.wq1

+

application/x-wq1

+

.wr1

+

application/x-wr1

+

.wri

+

application/x-wri

+

.wrk

+

application/x-wrk

+

.ws

+

application/x-ws

+

.ws2

+

application/x-ws

+

.wsc

+

text/scriptlet

+

.wsdl

+

text/xml

+

.wvx

+

video/x-ms-wvx

+

.xap

+

application/x-silverlight-app

+

.x_b

+

application/x-x_b

+

.xdp

+

application/vnd.adobe.xdp

+

.xdr

+

text/xml

+

.xfd

+

application/vnd.adobe.xfd

+

.xfdf

+

application/vnd.adobe.xfdf

+

.xhtml

+

text/html

+

.xls

+

application/vnd.ms-excel

+

.xls

+

application/x-xls

+

.xlsx

+

application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

+

.xltx

+

application/vnd.openxmlformats-officedocument.spreadsheetml.template

+

.xlw

+

application/x-xlw

+

.xml

+

text/xml

+

.xpl

+

audio/scpls

+

.xq

+

text/xml

+

.xql

+

text/xml

+

.xquery

+

text/xml

+

.xsd

+

text/xml

+

.xsl

+

text/xml

+

.xslt

+

text/xml

+

.xwd

+

application/x-xwd

+

.x_t

+

application/x-x_t

+

.yaml

+

text/vnd.yaml

+

.yml

+

text/vnd.yml

+

.webp

+

image/webp

+

.tar

+

application/x-tar

+

.zip

+

application/zip

+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_1703.html b/docs/obs_3rd_party/python_sdk/obs_22_1703.html new file mode 100644 index 000000000..e662c58fe --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_1703.html @@ -0,0 +1,14 @@ + + +

How Do I Get My Account ID and IAM User ID? (SDK for Python)

+

Obtaining the Account ID and User ID

When calling APIs, you may need to specify the account ID (DomainID) and user ID (UserID) in some requests. You need to obtain them from the console in advance. To obtain them from the console, do as follows:

+
  1. Log in to the management console.
  2. Hover the mouse pointer over the username and choose My Credentials from the drop-down list.

    On the My Credentials page, view the account ID and user ID.

    +

+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/obs_22_1704.html b/docs/obs_3rd_party/python_sdk/obs_22_1704.html new file mode 100644 index 000000000..0e37ee737 --- /dev/null +++ b/docs/obs_3rd_party/python_sdk/obs_22_1704.html @@ -0,0 +1,76 @@ + + +

Setting an Object Expiration Time (SDK for Python)

+

This example sets the object expiration time using a header when uploading a file stream.

+
obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    # Read a file stream.
+    content = open('localfile', 'rb')
+    bucketName = "examplebucket"
+    objectKey = "objectname"
+    header=PutObjectHeader()
+    #Set the expiration time.
+    header.expires=10
+    # Upload the file stream.
+    resp = obsClient.putContent(bucketName, objectkey, content,headers=header)
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Put Content Succeeded')
+        print('requestId:', resp.requestId)
+    else:
+        print('Put Content Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print(traceback.format_exc())
+

This example sets the object expiration time using a user-defined header when uploading a file stream.

+
obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    # Read a file stream.
+    content = open('localfile', 'rb')
+    bucketName = "examplebucket"
+    objectKey = "objectname"
+    header=PutObjectHeader()
+    # Use a user-defined header to set the expiration time.
+    extensionHeaders = {'x-obs-expires': 30}
+    # Upload the file stream.
+    resp = obsClient.putContent(bucketName, objectkey, content,extensionHeaders=extensionHeaders)
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Put Content Succeeded')
+        print('requestId:', resp.requestId)
+    else:
+        print('Put Content Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print(traceback.format_exc())
+

This example sets the expiration time for an uploaded object.

+
obsClient = ObsClient(access_key_id=ak, secret_access_key=sk, server=server)
+try:
+    bucketName = "examplebucket"
+    objectKey = "objectname"
+    # Use a user-defined header to set the expiration time.
+    extensionHeaders = {'x-obs-expires': 30}
+    # Configure metadata for the object.
+    resp = obsClient.setObjectMetadata(bucketName, objectkey, extensionHeaders=extensionHeaders)
+    # If status code 2xx is returned, the API is called successfully. Otherwise, the API call fails.
+    if resp.status < 300:
+        print('Set Object Metadata Succeeded')
+        print('requestId:', resp.requestId)
+    else:
+        print('Set Object Metadata Failed')
+        print('requestId:', resp.requestId)
+        print('errorCode:', resp.errorCode)
+        print('errorMessage:', resp.errorMessage)
+except:
+    print(traceback.format_exc())
+
+
+ +
+ diff --git a/docs/obs_3rd_party/python_sdk/public_sys-resources/caution_3.0-en-us.png b/docs/obs_3rd_party/python_sdk/public_sys-resources/caution_3.0-en-us.png new file mode 100644 index 000000000..60f607621 Binary files /dev/null and b/docs/obs_3rd_party/python_sdk/public_sys-resources/caution_3.0-en-us.png differ diff --git a/docs/obs_3rd_party/python_sdk/public_sys-resources/danger_3.0-en-us.png b/docs/obs_3rd_party/python_sdk/public_sys-resources/danger_3.0-en-us.png new file mode 100644 index 000000000..47a9c7235 Binary files /dev/null and b/docs/obs_3rd_party/python_sdk/public_sys-resources/danger_3.0-en-us.png differ diff --git a/docs/obs_3rd_party/python_sdk/public_sys-resources/delta.gif b/docs/obs_3rd_party/python_sdk/public_sys-resources/delta.gif new file mode 100644 index 000000000..0d1b1f674 Binary files /dev/null and b/docs/obs_3rd_party/python_sdk/public_sys-resources/delta.gif differ diff --git a/docs/obs_3rd_party/python_sdk/public_sys-resources/deltaend.gif b/docs/obs_3rd_party/python_sdk/public_sys-resources/deltaend.gif new file mode 100644 index 000000000..cc7da0fc8 Binary files /dev/null and b/docs/obs_3rd_party/python_sdk/public_sys-resources/deltaend.gif differ diff --git a/docs/obs_3rd_party/python_sdk/public_sys-resources/icon-arrowdn.gif b/docs/obs_3rd_party/python_sdk/public_sys-resources/icon-arrowdn.gif new file mode 100644 index 000000000..379428032 Binary files /dev/null and b/docs/obs_3rd_party/python_sdk/public_sys-resources/icon-arrowdn.gif differ diff --git a/docs/obs_3rd_party/python_sdk/public_sys-resources/icon-arrowrt.gif b/docs/obs_3rd_party/python_sdk/public_sys-resources/icon-arrowrt.gif new file mode 100644 index 000000000..6aaaa11c2 Binary files /dev/null and b/docs/obs_3rd_party/python_sdk/public_sys-resources/icon-arrowrt.gif differ diff --git a/docs/obs_3rd_party/python_sdk/public_sys-resources/icon-caution.gif b/docs/obs_3rd_party/python_sdk/public_sys-resources/icon-caution.gif new file mode 100644 index 000000000..079c79b26 Binary files /dev/null and b/docs/obs_3rd_party/python_sdk/public_sys-resources/icon-caution.gif differ diff --git a/docs/obs_3rd_party/python_sdk/public_sys-resources/icon-danger.gif b/docs/obs_3rd_party/python_sdk/public_sys-resources/icon-danger.gif new file mode 100644 index 000000000..079c79b26 Binary files /dev/null and b/docs/obs_3rd_party/python_sdk/public_sys-resources/icon-danger.gif differ diff --git a/docs/obs_3rd_party/python_sdk/public_sys-resources/icon-huawei.gif b/docs/obs_3rd_party/python_sdk/public_sys-resources/icon-huawei.gif new file mode 100644 index 000000000..a31d60f89 Binary files /dev/null and b/docs/obs_3rd_party/python_sdk/public_sys-resources/icon-huawei.gif differ diff --git a/docs/obs_3rd_party/python_sdk/public_sys-resources/icon-note.gif b/docs/obs_3rd_party/python_sdk/public_sys-resources/icon-note.gif new file mode 100644 index 000000000..31be2b039 Binary files /dev/null and b/docs/obs_3rd_party/python_sdk/public_sys-resources/icon-note.gif differ diff --git a/docs/obs_3rd_party/python_sdk/public_sys-resources/icon-notice.gif b/docs/obs_3rd_party/python_sdk/public_sys-resources/icon-notice.gif new file mode 100644 index 000000000..409070650 Binary files /dev/null and b/docs/obs_3rd_party/python_sdk/public_sys-resources/icon-notice.gif differ diff --git a/docs/obs_3rd_party/python_sdk/public_sys-resources/icon-tip.gif b/docs/obs_3rd_party/python_sdk/public_sys-resources/icon-tip.gif new file mode 100644 index 000000000..c47bae05c Binary files /dev/null and b/docs/obs_3rd_party/python_sdk/public_sys-resources/icon-tip.gif differ diff --git a/docs/obs_3rd_party/python_sdk/public_sys-resources/icon-warning.gif b/docs/obs_3rd_party/python_sdk/public_sys-resources/icon-warning.gif new file mode 100644 index 000000000..079c79b26 Binary files /dev/null and b/docs/obs_3rd_party/python_sdk/public_sys-resources/icon-warning.gif differ diff --git a/docs/obs_3rd_party/python_sdk/public_sys-resources/note_3.0-en-us.png b/docs/obs_3rd_party/python_sdk/public_sys-resources/note_3.0-en-us.png new file mode 100644 index 000000000..57a0e1f53 Binary files /dev/null and b/docs/obs_3rd_party/python_sdk/public_sys-resources/note_3.0-en-us.png differ diff --git a/docs/obs_3rd_party/python_sdk/public_sys-resources/notice_3.0-en-us.png b/docs/obs_3rd_party/python_sdk/public_sys-resources/notice_3.0-en-us.png new file mode 100644 index 000000000..fa4b64990 Binary files /dev/null and b/docs/obs_3rd_party/python_sdk/public_sys-resources/notice_3.0-en-us.png differ diff --git a/docs/obs_3rd_party/python_sdk/public_sys-resources/warning_3.0-en-us.png b/docs/obs_3rd_party/python_sdk/public_sys-resources/warning_3.0-en-us.png new file mode 100644 index 000000000..def5c3565 Binary files /dev/null and b/docs/obs_3rd_party/python_sdk/public_sys-resources/warning_3.0-en-us.png differ