当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Service_Amazon_S3::isObjectAvailable方法代码示例

本文整理汇总了PHP中Zend_Service_Amazon_S3::isObjectAvailable方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Service_Amazon_S3::isObjectAvailable方法的具体用法?PHP Zend_Service_Amazon_S3::isObjectAvailable怎么用?PHP Zend_Service_Amazon_S3::isObjectAvailable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Service_Amazon_S3的用法示例。


在下文中一共展示了Zend_Service_Amazon_S3::isObjectAvailable方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testIsObjectAvailableWithSpacesInKey

 /**
  * Test that isObjectAvailable() works if object name contains spaces
  *
  * @depends testCreateBucket
  * @depends testObjectPath
  *
  * ZF-10017
  */
 public function testIsObjectAvailableWithSpacesInKey()
 {
     $this->_amazon->createBucket($this->_bucket);
     $filedir = dirname(__FILE__) . "/_files/";
     $key = $this->_bucket . '/subdir/another dir with spaces/zftestfile.html';
     $this->_amazon->putFile($filedir . "testdata.html", $key);
     $this->assertTrue($this->_amazon->isObjectAvailable($key));
 }
开发者ID:jsnshrmn,项目名称:Suma,代码行数:16,代码来源:OnlineTest.php

示例2: testMoveObject

 /**
  * @depends testCopyObject
  * @depends testRemoveObject
  */
 public function testMoveObject()
 {
     $this->_amazon->createBucket($this->_bucket);
     $data = "testdata";
     $this->_amazon->putObject($this->_bucket . "/zftest", $data);
     $info1 = $this->_amazon->getInfo($this->_bucket . "/zftest");
     $this->_amazon->moveObject($this->_bucket . "/zftest", $this->_bucket . "/zftest2");
     $this->assertFalse($this->_amazon->isObjectAvailable($this->_bucket . "/zftest"));
     $this->assertTrue($this->_amazon->isObjectAvailable($this->_bucket . "/zftest2"));
     $info2 = $this->_amazon->getInfo($this->_bucket . "/zftest2");
     $this->assertEquals($info1['etag'], $info2['etag']);
 }
开发者ID:navassouza,项目名称:zf2,代码行数:16,代码来源:OnlineTest.php

示例3: testPutNoFile

 public function testPutNoFile()
 {
     $filedir = dirname(__FILE__) . "/_files/";
     try {
         $this->_amazon->putFile($filedir . "nosuchfile", $this->_bucket . "/zftestfile");
         $this->fail("Expected exception not thrown");
     } catch (Zend_Service_Amazon_S3_Exception $e) {
         $this->assertContains("Cannot read", $e->getMessage());
         $this->assertContains("nosuchfile", $e->getMessage());
     }
     $this->assertFalse($this->_amazon->isObjectAvailable($this->_bucket . "/zftestfile"));
 }
开发者ID:vicfryzel,项目名称:zf,代码行数:12,代码来源:OnlineTest.php

示例4: 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}'.");
     }
 }
开发者ID:lchen01,项目名称:STEdwards,代码行数:19,代码来源:ZendS3.php

示例5: upload

 public function upload($observer)
 {
     $product = $observer->getEvent()->getProduct();
     //There's nothing to process because we're using images
     //from original product in duplicate
     if ($product->getIsDuplicate() || $product->getData('mventory_update_duplicate')) {
         return;
     }
     $images = $observer->getEvent()->getImages();
     //Use product helper from MVentory_API if it's installed and is activated
     //The helper is used to get correct store for the product when MVentory_API
     //extension is used
     //Change current store if product's store is different for correct
     //file name of images
     if (Mage::helper('core')->isModuleEnabled('MVentory_API')) {
         $store = Mage::helper('mventory/product')->getWebsite($product)->getDefaultStore();
         $changeStore = $store->getId() != Mage::app()->getStore()->getId();
     } else {
         $store = Mage::app()->getStore();
         $changeStore = false;
     }
     //Get settings for S3
     $accessKey = $store->getConfig(MVentory_CDN_Model_Config::ACCESS_KEY);
     $secretKey = $store->getConfig(MVentory_CDN_Model_Config::SECRET_KEY);
     $bucket = $store->getConfig(MVentory_CDN_Model_Config::BUCKET);
     $prefix = $store->getConfig(MVentory_CDN_Model_Config::PREFIX);
     $dimensions = $store->getConfig(MVentory_CDN_Model_Config::DIMENSIONS);
     $cacheTime = (int) $store->getConfig(MVentory_CDN_Model_Config::CACHE_TIME);
     //Return if S3 settings are empty
     if (!($accessKey && $secretKey && $bucket && $prefix)) {
         return;
     }
     //Build prefix for all files on S3
     $cdnPrefix = $bucket . '/' . $prefix . '/';
     //Parse dimension. Split string to pairs of width and height
     $dimensions = str_replace(', ', ',', $dimensions);
     $dimensions = explode(',', $dimensions);
     //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);
     if ($cacheTime > 0) {
         $meta[MVentory_CDN_Model_Config::AMAZON_CACHE_CONTROL] = 'max-age=' . $cacheTime;
     }
     if ($changeStore) {
         $emu = Mage::getModel('core/app_emulation');
         $origEnv = $emu->startEnvironmentEmulation($store);
     }
     $config = Mage::getSingleton('catalog/product_media_config');
     $s3 = new Zend_Service_Amazon_S3($accessKey, $secretKey);
     foreach ($images['images'] as &$image) {
         //Process new images only
         if (isset($image['value_id'])) {
             continue;
         }
         //Get name of the image and create its key on S3
         $fileName = $image['file'];
         $cdnPath = $cdnPrefix . 'full' . $fileName;
         //Full path to uploaded image
         $file = $config->getMediaPath($fileName);
         //Check if object with the key exists
         if ($s3->isObjectAvailable($cdnPath)) {
             $position = strrpos($fileName, '.');
             //Split file name and extension
             $name = substr($fileName, 0, $position);
             $ext = substr($fileName, $position);
             //Search key
             $_key = $prefix . '/full' . $name . '_';
             //Get all objects which is started with the search key
             $keys = $s3->getObjectsByBucket($bucket, array('prefix' => $_key));
             $index = 1;
             //If there're objects which names begin with the search key then...
             if (count($keys)) {
                 $extLength = strlen($ext);
                 $_keys = array();
                 //... store object names without extension as indeces of the array
                 //for fast searching
                 foreach ($keys as $key) {
                     $_keys[substr($key, 0, -$extLength)] = true;
                 }
                 //Find next unused object name
                 while (isset($_keys[$_key . $index])) {
                     ++$index;
                 }
                 unset($_keys);
             }
             //Build new name and path with selected index
             $fileName = $name . '_' . $index . $ext;
             $cdnPath = $cdnPrefix . 'full' . $fileName;
             //Get new name for uploaded file
             $_file = $config->getMediaPath($fileName);
             //Rename file uploaded to Magento
             rename($file, $_file);
             //Update values of media attribute in the product after renaming
             //uploaded image if the image was marked as 'image', 'small_image'
             //or 'thumbnail' in the product
             foreach ($product->getMediaAttributes() as $mediaAttribute) {
                 $code = $mediaAttribute->getAttributeCode();
                 if ($product->getData($code) == $image['file']) {
                     $product->setData($code, $fileName);
                 }
             }
//.........这里部分代码省略.........
开发者ID:sebastianwahn,项目名称:MVentory_S3CDN,代码行数:101,代码来源:Observer.php

示例6: exists

 public function exists($filename)
 {
     $this->_initApi();
     return $this->_api->isObjectAvailable($this->_config['bucket'] . $this->_getUri($filename));
 }
开发者ID:grrr-amsterdam,项目名称:garp3,代码行数:5,代码来源:S3.php

示例7: foreach

 foreach ($destSubdirs as $destSubdir) {
     $placeholder = Mage::getModel('catalog/product_image')->setDestinationSubdir($destSubdir)->setBaseFile(null)->getBaseFile();
     $result = copy($placeholder, $config->getMediaPath(basename($placeholder)));
     if ($result === true) {
         $images[] = '/' . basename($placeholder);
     } else {
         Mage::log('Error on copy ' . $placeholder . ' to media folder', null, 's3.log');
     }
 }
 $s3 = new Zend_Service_Amazon_S3($accessKey, $secretKey);
 $imageNumber = 1;
 foreach ($images as $fileName) {
     Mage::log('Processing image ' . $imageNumber++ . ' of ' . $totalImages, null, 's3.log');
     $cdnPath = $cdnPrefix . 'full' . $fileName;
     $file = $config->getMediaPath($fileName);
     if (!$s3->isObjectAvailable($cdnPath)) {
         Mage::log('Trying to upload original file ' . $file . ' as ' . $cdnPath, null, 's3.log');
         try {
             $s3->putFile($file, $cdnPath, $meta);
         } catch (Exception $e) {
             Mage::log($e->getMessage(), null, 's3.log');
             continue;
         }
     } else {
         Mage::log('File ' . $file . ' has been already uploaded', null, 's3.log');
     }
     if (!count($dimensions)) {
         continue;
     }
     foreach ($dimensions as $dimension) {
         $newCdnPath = $cdnPrefix . $dimension . $fileName;
开发者ID:sebastianwahn,项目名称:MVentory_S3CDN,代码行数:31,代码来源:upload-to-s3.php


注:本文中的Zend_Service_Amazon_S3::isObjectAvailable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。