getMessage() . "\n"); return null; } return $ossClient; } public static function getBucketName() { return getenv('OSS_BUCKET'); } public static function getRegion() { return getenv('OSS_REGION'); } public static function getCallbackUrl() { return getenv('OSS_CALLBACK_URL'); } /** * Tool method, create a bucket */ public static function createBucket() { $ossClient = self::getOssClient(); if (is_null($ossClient)) exit(1); $bucket = self::getBucketName(); $acl = OssClient::OSS_ACL_TYPE_PUBLIC_READ; try { $ossClient->createBucket($bucket, $acl); } catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return; } print(__FUNCTION__ . ": OK" . "\n"); } /** * Wait for bucket meta sync */ public static function waitMetaSync() { if (getenv('TRAVIS')) { sleep(10); } } }