Esta página aún no está disponible en su idioma local. Estamos trabajando arduamente para agregar más versiones de idiomas. Gracias por tu apoyo.
Initializing an Instance of ObsClient
API Description
ObsClient functions as the BrowserJS client for accessing OBS. It offers users a series of APIs for interaction with OBS. These APIs are used for managing and operating resources, such as buckets and objects, stored in OBS.
Method Definition
1. Constructor form: ObsClient(parameter) 2. Factory form: ObsClient.factory(parameter)
Parameter Description
Field |
Type |
Optional or Mandatory |
Description |
---|---|---|---|
access_key_id |
String |
Optional |
AK |
secret_access_key |
String |
Optional |
SK |
server |
String |
Mandatory |
Endpoint for accessing OBS, which contains the protocol type, domain name (or IP address), and port number. For example, https://your-endpoint:443. |
timeout |
Number |
Optional |
The total timeout period (in seconds) of an HTTP/HTTPS request. The default value is 300. If the network is unstable or the size of the file to be uploaded is large, you are advised to set a larger value for timeout. |
is_cname |
Boolean |
Optional |
Whether to use self-defined domain name to access OBS. The default value is false. |
useRawXhr |
Boolean |
Optional |
Whether to use the native XHR to send Ajax requests. The default value is false. |
Sample Code
// Create an instance of ObsClient. var obsClient = new ObsClient({ // Hard-coded or plaintext AK/SK are risky. For security purposes, encrypt your AK/SK and store them in the configuration file or environment variables. In this example, the AK/SK are stored in environment variables for identity authentication. Before running this example, configure environment variables AccessKeyID and SecretAccessKey. // The front-end code does not have the process environment variable, so you need to use a module bundler like webpack to define the process variable. // Obtain an AK/SK pair on the management console. For details, see https://support.huaweicloud.com/eu/usermanual-ca/ca_01_0003.html. access_key_id: process.env.AccessKeyID, secret_access_key: process.env.SecretAccessKey, timeout : 300, //EU-Dublin region is used here as an example. Replace it with the one in your actual situation. server: 'https://obs.eu-west-101.myhuaweicloud.com' });
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.