Файл: includes/Upload.class.php
Строк: 52
<?php
/**
* ====================================================================================
* PremiumMediaScript (c) KBRmedia
* ----------------------------------------------------------------------------------
* @copyright This software is exclusively sold at CodeCanyon.net. If you have downloaded this
* from another site or received it from someone else than me, then you are engaged
* in an illegal activity. You must delete this software immediately or buy a proper
* license from http://codecanyon.net/user/KBRmedia/portfolio?ref=KBRmedia.
* ====================================================================================
*
*
* @author KBRmedia (http://gempixel.com)
* @link http://gempixel.com
* @license http://gempixel.com/license
* @package PremiumMediaScript
* @subpackage Meme Handler
*/
use AwsS3S3Client;
class Upload{
/**
* S3
* @var null
*/
protected $s3 = NULL;
protected $bucket = NULL;
/**
* [__construct description]
*/
public function __construct($region, $public, $private, $bucket){
require(ROOT.'/includes/library/aws/aws-autoloader.php');
$this->s3 = new S3Client(array(
'version' => 'latest',
'region' => $region,
'credentials' => array(
'key' => $public,
'secret' => $private,
),
'scheme' => 'http'
));
$this->bucket = $bucket;
}
/**
* Upload
*/
public function save($name, $file){
try {
$upload = $this->s3->upload($this->bucket, $name, fopen($file, 'rb'), 'public-read');
return $upload->get('ObjectURL');
} catch(Exception $e) {
return FALSE;
}
}
public function delete($name){
$name = explode("/{$this->bucket}/",$name);
$name = $name[1];
return $this->s3->deleteObject(array("Bucket" => $this->bucket, "Key" => $name));
}
}