first commit

This commit is contained in:
pakerpale
2020-06-10 06:19:03 +09:00
commit cd6b5b7832
6081 changed files with 624389 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
<?php
require APPPATH . 'third_party/aws/autoloader.php';
use Aws\S3\S3Client;
class Awsfileuploader
{
private $CI;
private $bucket = 'cm-img';
private $accessKey = 'AKIA2WGASVZ5TQZDCANX';
private $secretAccessKey = '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';
private $s3;
public function __construct()
{
$this->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
));
}
}