示例#1
0
			$fileExt .= $fileName[$i];
		}
	 
	 $fileExt = ".".strrev($fileExt);

	 //Create the image
	 require_once('/var/www/html/api/image/obj/Image.php');
	 $Image = new Image(NULL, $PDOconn);
	 
	 //Generate new filename
	 $Image->ID = $Image->generateUniqueID();
	 $newFileName = $Image->ID;
	 $newFileNameWithExt = $newFileName.$fileExt;

	 $accessKey = CDConsts::getConst("AWS_ACCESS_KEY", 'charValue', $PDOconn);
	 $secretKey = CDConsts::getConst("AWS_SECRET_KEY", 'charValue', $PDOconn);
	 
	 $client = S3Client::factory(array(
	   'key' => $accessKey,
	   'secret' => $secretKey
	 ));
	 
    //Get the bucket
	$cdimageBucket;
	$bucketName = "greatdays";
	$result = $client->listBuckets();
      
	foreach ($result['Buckets'] as $bucket) {
	// Each Bucket value will contain a Name and CreationDate
		
		if($bucket['Name'] == $bucketName)
示例#2
0
	public function delete()
	{
		if(!$this->exists) return false;
	
		$accessKey = CDConsts::getConst("AWS_ACCESS_KEY", 'charValue', $this->PDOconn);
		$secretKey = CDConsts::getConst("AWS_SECRET_KEY", 'charValue', $this->PDOconn);
	 
		$client = S3Client::factory(array(
		   'key' => $accessKey,
		   'secret' => $secretKey
		));
	
		$result = $client->deleteObject(array(
		  'Bucket' => 'greatdays',
		  'Key'    => "/img/".$this->row['filename']
		));

		$sql = "DELETE FROM image WHERE objectID=:objectID";
		$stmtB = $this->PDOconn->prepare($sql);
		$paramsB[':objectID'] = $this->ID;
		$stmtB->execute($paramsB);
		
		return true;
	}