accessKeyId = $accessKeyId; return $this; } /** * @param string $secretAccessKey * @return $this */ public function secretAccessKey(string $secretAccessKey) { $this->secretAccessKey = $secretAccessKey; return $this; } /** * @param string $endpoint * @return $this */ public function endpoint(string $endpoint) { $this->endpoint = $endpoint; return $this; } /** * @param string $bucket * @return $this */ public function bucket(string $bucket) { $this->bucket = $bucket; return $this; } /** * @param string $object * @param string $filePath * @return mixed * @throws Exception */ public function upload(string $object, string $filePath) { // 设置BosClient的Access Key ID、Secret Access Key和ENDPOINT $BOS_TEST_CONFIG = array( 'credentials' => array( 'accessKeyId' => $this->accessKeyId, 'secretAccessKey' => $this->secretAccessKey, ), 'endpoint' => $this->endpoint, ); $client = new BosClient($BOS_TEST_CONFIG); // 从文件中直接上传Object return $client->putObjectFromFile($this->bucket, $object, $filePath); } }