本文整理汇总了PHP中Zend_Service_Amazon_S3::removeObject方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Service_Amazon_S3::removeObject方法的具体用法?PHP Zend_Service_Amazon_S3::removeObject怎么用?PHP Zend_Service_Amazon_S3::removeObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Service_Amazon_S3
的用法示例。
在下文中一共展示了Zend_Service_Amazon_S3::removeObject方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: gc
public function gc()
{
$config = self::$_registry->get("config");
$s3config = $config['services']['S3'];
$s3 = new Zend_Service_Amazon_S3($s3config['key'], $s3config['secret']);
$select = $this->_dbTable->select();
$select->order("timestamp ASC")->limit(50);
$delShares = $this->_dbAdapter->fetchAll($select);
$deletedShares = array();
foreach ($delShares as $delShare) {
$objectKey = $delShare['alias'] . "/" . $delShare['share'] . "-" . $delShare['download_secret'] . "/" . $delShare['filename'];
$object = $s3config['sharesBucket'] . "/" . $objectKey;
if ($s3->removeObject($object)) {
$deletedShares[] = $delShare['id'];
}
}
if (!empty($deletedShares)) {
$querystring = "DELETE from " . $this->_dbAdapter->quoteTableAs($this->_dbTable->getTableName()) . " WHERE ";
do {
$line = $this->_dbAdapter->quoteInto("id = ?", current($deletedShares));
$querystring .= $line;
next($deletedShares);
if (current($deletedShares)) {
$querystring .= " OR ";
}
} while (current($deletedShares));
$this->_dbAdapter->query($querystring);
}
$removedNum = count($deletedShares);
return $removedNum;
}
示例2: deleteItem
/**
* Delete an item in the storage service.
*
* @param string $path
* @param array $options
* @return void
*/
public function deleteItem($path, $options = array())
{
try {
$this->_s3->removeObject($this->_getFullPath($path, $options));
} catch (Zend_Service_Amazon_S3_Exception $e) {
throw new Zend_Cloud_StorageService_Exception('Error on delete: ' . $e->getMessage(), $e->getCode(), $e);
}
}
示例3: syncDirectory
public function syncDirectory()
{
$accessKey = Mage::getStoreConfig('amazonsync/general/access_key_id');
$secretKey = Mage::getStoreConfig('amazonsync/general/secret_access_key');
$bucket = Mage::getStoreConfig('amazonsync/general/s3_bucket_path');
$prefix = Mage::getStoreConfig('amazonsync/general/prefix');
$magentoDir = Mage::getStoreConfig('amazonsync/general/magento_directory');
$magentoDir = Mage::getBaseDir() . "/" . $magentoDir;
//Return if S3 settings are empty
if (!($accessKey && $secretKey && $bucket)) {
return;
}
//Prepare meta data for uploading. All uploaded images are public
$meta = array(Zend_Service_Amazon_S3::S3_ACL_HEADER => Zend_Service_Amazon_S3::S3_ACL_PUBLIC_READ);
$s3 = new Zend_Service_Amazon_S3($accessKey, $secretKey);
//Build prefix for all files on S3
if ($prefix) {
$cdnPrefix = $bucket . '/' . $prefix;
} else {
$cdnPrefix = $bucket;
}
$allFiles = array();
if (is_dir($magentoDir)) {
$objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($magentoDir), RecursiveIteratorIterator::SELF_FIRST);
$dir = null;
foreach ($objects as $name => $object) {
//Get name of the file and create its key on S3
if (!($object->getFileName() == '.' || $object->getFileName() == '..')) {
if (is_dir($object)) {
continue;
}
$fileName = str_replace($magentoDir, '', $name);
$cdnPath = $cdnPrefix . $fileName;
//Full path to uploaded file
$file = $name;
//Upload original file
$allFiles[] = $cdnPath;
if (!$s3->putFile($file, $cdnPath, $meta)) {
$msg = 'Can\'t upload original image (' . $file . ') to S3 with ' . $cdnPath . ' key';
throw new Mage_Core_Exception($msg);
}
}
}
//Remove Not Matched Files
foreach ($s3->getObjectsByBucket($bucket) as $object) {
$object = $bucket . '/' . $object;
if (!in_array($object, $allFiles)) {
$s3->removeObject($object);
}
}
return 'All files uploaded to S3 with ' . $bucket . ' bucket';
} else {
$msg = $magentoDir . ' directory does not exist';
throw new Mage_Core_Exception($msg);
}
}
示例4: testGetObjectsByBucketParams
/**
* @group ZF-7773
*/
public function testGetObjectsByBucketParams()
{
$this->_amazon->createBucket("testgetobjectparams1");
$this->_amazon->putObject("testgetobjectparams1/zftest1", "testdata");
$this->_amazon->putObject("testgetobjectparams1/zftest2", "testdata");
$list = $this->_amazon->getObjectsByBucket("testgetobjectparams1", array('max-keys' => 1));
$this->assertEquals(1, count($list));
$this->_amazon->removeObject("testgetobjectparams1/zftest1", "testdata");
$this->_amazon->removeObject("testgetobjectparams1/zftest2", "testdata");
$this->_amazon->removeBucket("testgetobjectparams1");
}
示例5: s3_delete_file
function s3_delete_file($access_key_id, $secret_access_key, $bucket_path)
{
$result = FALSE;
if ($access_key_id && $secret_access_key && $bucket_path) {
try {
$s3 = new Zend_Service_Amazon_S3($access_key_id, $secret_access_key);
if ($s3->removeObject($bucket_path)) {
$result = TRUE;
}
} catch (Exception $ex) {
//print $ex->getMessage();
}
}
}
示例6: delete
/**
* Remove a "stored" file.
*
* @param string $path
*/
public function delete($path)
{
$objectName = $this->_getObjectName($path);
$status = $this->_s3->removeObject($objectName);
if (!$status) {
if ($this->_s3->isObjectAvailable($objectName)) {
throw new Omeka_Storage_Exception('Unable to delete file.');
} else {
_log("Omeka_Storage_Adapter_ZendS3: Tried to delete missing object '{$objectName}'.", Zend_Log::WARN);
}
} else {
_log("Omeka_Storage_Adapter_ZendS3: Removed object '{$objectName}'.");
}
}
示例7: remove
public function remove($filename)
{
$this->_initApi();
return $this->_api->removeObject($this->_config['bucket'] . $this->_getUri($filename));
}
示例8: removeAmazonS3Object
/**
* Removes the object specified by the file name and user id
* @param unknown_type $user_id
* @param unknown_type $file_name
* @return boolean
*/
private function removeAmazonS3Object($user_id, $file_name)
{
// TODO: make this asynchronous later
global $app;
$objectURL = null;
$aws_key = null;
$aws_secret_key = null;
$aws_key = $app->configData['configuration']['api_keys']['value']['amazon_aws_key']['value'];
$aws_secret_key = $app->configData['configuration']['api_keys']['value']['amazon_aws_secret']['value'];
$amazon_bucket_name = $app->configData['configuration']['api_keys']['value']['amazon_s3_bucket']['value'];
if (isset($aws_key) && isset($aws_secret_key)) {
$s3 = null;
$bucketAvailable = false;
$s3 = new Zend_Service_Amazon_S3($aws_key, $aws_secret_key);
$bucketAvailable = $s3->isBucketAvailable($amazon_bucket_name);
if ($bucketAvailable) {
// bucket is available so try to delete the object
try {
foreach ($this->_image_sizes as $imageSizeType => $imageDimensions) {
$objectPath = $this->buildAmazonS3ObjectURL($imageSizeType, $user_id, $file_name);
$objectPath = $amazon_bucket_name . $objectPath;
$s3->removeObject($objectPath);
}
return true;
} catch (Exception $e) {
// ignore this error - the extra amazons3 object in the bucket
// will not harm anything. It will just be an unclean directory
// take care of cleaning asynchronously by deleting orphan objects
// that do not appear in the user's picture/avatar urls
//$this->message = $e->getMessage();
}
} else {
// no bucket is available
return false;
}
}
return false;
}
示例9: removeFile
public function removeFile($path)
{
// Should we add bucket here?
$path = $this->_bucket . '/' . $path;
$this->_internalService->removeObject($path);
}
示例10: deleteFiles
public function deleteFiles($userInfo)
{
$registry = Zend_Registry::getInstance();
$config = $registry->get("config");
$s3config = $config['services']['S3'];
$avatarInfo = unserialize($userInfo['avatarInfo']);
if (!isset($avatarInfo['secret'])) {
return false;
}
$s3 = new Zend_Service_Amazon_S3($s3config['key'], $s3config['secret']);
foreach ($this->_sizes as $sizeInfo) {
$s3->removeObject($s3config['headshotsBucket'] . "/" . $userInfo['id'] . '-' . $avatarInfo['secret'] . $sizeInfo[1] . '.jpg');
}
return true;
}