accessKeyId = $accessKeyId; return $this; } /** * @param string $accessKeySecret * @return $this */ public function accessKeySecret(string $accessKeySecret) { $this->accessKeySecret = $accessKeySecret; return $this; } /** * @param string $endpoint * @return $this */ public function endpoint(string $endpoint): self { $this->endpoint = $endpoint; return $this; } /** * @param string $bucket * @return $this */ public function bucket(string $bucket): self { $this->bucket = $bucket; return $this; } /** * @param string $object * @param string $filePath * @return bool */ public function upload(string $object, string $filePath): bool { try { $ossClient = new OssClient($this->accessKeyId, $this->accessKeySecret, $this->endpoint); $ossClient->uploadFile($this->bucket, $object, $filePath); return true; } catch (OssException $e) { return false; } } }