'LTAIy9x1zb2qhNfI', 'accessKeySecret' => 'I5whhorQVfJji2yVk3N0xtFzL3sUr1', 'endPoint' => 'oss-cn-shenzhen.aliyuncs.com', ]; } public function testOssClient() { $config = static::$ossConfig; $imagePath = "http://p1.pstatp.com/large/pgc-image/1523870471647f8800fad69"; $bucket = 'lrlz-image'; $filename = sha1($imagePath); ini_set('error_reporting', 0); $content = file_get_contents($imagePath); if (! $content) { return false; } $filetype = getImageType($content); if ($filetype == 'unknown') { return false; } $filename .= ".{$filetype}"; try { $client = new OssClient($config['accessKeyId'], $config['accessKeySecret'], $config['endPoint']); $ret = $client->putObject($bucket, $filename, $content); if (! empty($ret)) { return $ret['oss-request-url']; } } catch (OssException $ex) { Log::record("upload image to Aliyun oss failed: {$ex->getMessage()}",Log::ERR); return false; } return false; } }