ObsClient Initialization
API Description
ObsClient functions as the PHP client for accessing OBS. It offers callers 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.
Namespace
Class |
Parent Namespace |
---|---|
ObsClient |
Obs |
Method Definition
1. Constructor form: ObsClient(array $parameter) 2. Factory form: ObsClient::factory(array $parameter)
Parameter Description
Field |
Type |
Optional or Mandatory |
Description |
---|---|---|---|
key |
string |
Mandatory |
AK |
secret |
string |
Mandatory |
SK |
endpoint |
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. To view the endpoints available for OBS, see Regions and Endpoints. |
ssl_verify |
boolean or string |
Optional |
Whether to verify server-side certificates. Possible values are:
The default value is false. |
max_retry_count |
integer |
Optional |
Maximum number of retries when an HTTP/HTTPS connection is abnormal. The default value is 3. |
socket_timeout |
integer |
Optional |
Timeout duration for transmitting data at the socket layer, in seconds. The default value is 60. |
connect_timeout |
integer |
Optional |
Timeout period for establishing an HTTP/HTTPS connection, in seconds. The default value is 60. |
chunk_size |
integer |
Optional |
Block size for reading socket streams, in bytes. The default value is 65536. |
Sample Code
// Import the dependency library. require 'vendor/autoload.php'; // Import the SDK code library during source code installation. // require 'obs-autoloader.php'; // Declare the namespace. use Obs\ObsClient; // Create an instance of ObsClient. $obsClient = new ObsClient([ //Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage. //Obtain an AK/SK pair on the management console. For details, see https://support.huaweicloud.com/intl/en-us/usermanual-ca/ca_01_0003.html. 'key' => getenv('ACCESS_KEY_ID'), 'secret' => getenv('SECRET_ACCESS_KEY'), 'endpoint' => 'https://your-endpoint', 'ssl_verify' => false, 'max_retry_count' => 1, 'socket_timeout' => 20, 'connect_timeout' => 20, 'chunk_size' => 8196 ]);
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot