CI = &get_instance(); $this->CI->load->helper('string'); $credentials = new Aws\Credentials\Credentials($this->accessKey, $this->secretAccessKey); $this->s3 = new S3Client(array( 'version' => 'latest', 'region' => 'ap-northeast-2', 'credentials' => $credentials, 'scheme' => 'http', )); } public function upload($filePath, $keyPath) { $result = $this->s3->putObject(array( 'Bucket' => $this->bucket, 'Key' => $keyPath, 'Body' => fopen($filePath, 'r'), 'ACL' => 'public-read', )); @unlink($filePath); return '/'. $keyPath; } public function delete($keyPath) { $result = $this->s3->deleteObject(array( 'Bucket' => $this->bucket, 'Key' => $keyPath )); } }