$ak, 'secret' => $sk, 'endpoint' => $endpoint, 'socket_timeout' => 30, 'connect_timeout' => 10 ] ); try { /* * Create bucket */ echo "Create a new bucket for demo\n\n"; $obsClient -> createBucket(['Bucket' => $bucketName]); /* * Create an empty folder without request body, note that the key must be * suffixed with a slash */ $keySuffixWithSlash = "MyObjectKey1/"; $obsClient -> putObject(['Bucket' => $bucketName, 'Key' => $keySuffixWithSlash]); echo "Creating an empty folder " . $keySuffixWithSlash . "\n\n"; /* * Verify whether the size of the empty folder is zero */ $resp = $obsClient -> getObject(['Bucket' => $bucketName, 'Key' => $keySuffixWithSlash]); echo "Size of the empty folder '" . $keySuffixWithSlash. "' is " . $resp['ContentLength'] . "\n\n"; if($resp['Body']){ $resp['Body'] -> close(); } /* * Create an object under the folder just created */ $obsClient -> putObject(['Bucket' => $bucketName, 'Key' => $keySuffixWithSlash . $objectKey, 'Body' => 'Hello OBS']); } catch ( ObsException $e ) { echo 'Response Code:' . $e->getStatusCode () . PHP_EOL; echo 'Error Message:' . $e->getExceptionMessage () . PHP_EOL; echo 'Error Code:' . $e->getExceptionCode () . PHP_EOL; echo 'Request ID:' . $e->getRequestId () . PHP_EOL; echo 'Exception Type:' . $e->getExceptionType () . PHP_EOL; } finally{ $obsClient->close (); }