• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Zend_Service_Amazon_S3类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: isValid

 public function isValid($data)
 {
     $valid = parent::isValid($data);
     // Custom valid
     if ($valid) {
         // Check auth
         try {
             $testService = new Zend_Service_Amazon_S3($data['accessKey'], $data['secretKey'], $data['region']);
             $buckets = $testService->getBuckets();
         } catch (Exception $e) {
             $this->addError('Please double check your access keys.');
             return false;
         }
         // Check bucket
         try {
             if (!in_array($data['bucket'], $buckets)) {
                 if (!$testService->createBucket($data['bucket'], $data['region'])) {
                     throw new Exception('Could not create or find bucket');
                 }
             }
         } catch (Exception $e) {
             $this->addError('Bucket name is already taken and could not be created.');
             return false;
         }
     }
     return $valid;
 }
开发者ID:febryantosulistyo,项目名称:ClassicSocial,代码行数:27,代码来源:S3.php


示例2: 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;
 }
开发者ID:henvic,项目名称:MediaLab,代码行数:31,代码来源:RemoveFiles.php


示例3: _sendS3

 private function _sendS3($tmpfile, $name)
 {
     $config = new Zend_Config_Ini('../application/configs/amazon.ini', 's3');
     $s3 = new Zend_Service_Amazon_S3($config->access_key, $config->secret_key);
     $bytes = file_get_contents($tmpfile);
     return $s3->putObject($config->imagebucket . "/" . $name . ".jpg", $bytes, array(Zend_Service_Amazon_S3::S3_ACL_HEADER => Zend_Service_Amazon_S3::S3_ACL_PUBLIC_READ));
 }
开发者ID:austinphp,项目名称:AustinPHP,代码行数:7,代码来源:IndexController.php


示例4: 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);
     }
 }
开发者ID:brentwpeterson,项目名称:magento-amazon-s3-sync,代码行数:56,代码来源:Syncfile.php


示例5: setUp

 /**
  * Sets up this test case
  *
  * @return void
  */
 public function setUp()
 {
     Zend_Service_Amazon_S3::setKeys(constant('TESTS_ZEND_SERVICE_AMAZON_ONLINE_ACCESSKEYID'), constant('TESTS_ZEND_SERVICE_AMAZON_ONLINE_SECRETKEYID'));
     if (!stream_wrapper_register('s3', 'Zend_Service_Amazon_S3')) {
         $this->fail('Unable to register s3:// streams wrapper');
     }
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:12,代码来源:OnlineTest.php


示例6: fetchMetadata

 /**
  * Get a key/value array of metadata for the given path.
  *
  * @param  string $path
  * @param  array $options
  * @return array
  */
 public function fetchMetadata($path, $options = array())
 {
     try {
         return $this->_s3->getInfo($this->_getFullPath($path, $options));
     } catch (Zend_Service_Amazon_S3_Exception $e) {
         throw new Zend_Cloud_StorageService_Exception('Error on fetch: ' . $e->getMessage(), $e->getCode(), $e);
     }
 }
开发者ID:laiello,项目名称:vinhloi,代码行数:15,代码来源:S3.php


示例7: indexAction

 public function indexAction()
 {
     $s3 = new Zend_Service_Amazon_S3('AKIAJ5HTOSBB7ITPA6VQ', 'n8ZjV8xz/k/FxBGhrVduYlSXVFFmep7aZJ/NOsoj');
     $this->view->buckets = $s3->getBuckets();
     $bucketName = 'vaultman';
     $ret = $s3->getObjectsByBucket($bucketName);
     $this->view->objects = $ret;
     $this->view->form = new Mybase_Form_Files();
     $formData = $this->getRequest()->getPost();
     if ($this->_request->isPost()) {
         $s3->registerStreamWrapper("s3");
         //file_put_contents("s3://".$bucketName."/".$_FILES['img']['name'], fopen($_FILES['img']['tmp_name'], 'r'));
         $adapter = new Zend_File_Transfer_Adapter_Http();
         $adapter->setDestination("s3://" . $bucketName . "/");
         //$adapter->receive();
     }
 }
开发者ID:besters,项目名称:My-Base,代码行数:17,代码来源:FilesController.php


示例8: s3_put_file

function s3_put_file($access_key_id, $secret_access_key, $bucket_path, $file_path, $mime)
{
    $result = FALSE;
    if ($access_key_id && $secret_access_key && $bucket_path && $file_path) {
        try {
            $s3 = new Zend_Service_Amazon_S3($access_key_id, $secret_access_key);
            $meta = array();
            $meta[Zend_Service_Amazon_S3::S3_ACL_HEADER] = Zend_Service_Amazon_S3::S3_ACL_PUBLIC_READ;
            if ($mime) {
                $meta[Zend_Service_Amazon_S3::S3_CONTENT_TYPE_HEADER] = $mime;
            }
            if ($s3->putFileStream($file_path, $bucket_path, $meta)) {
                $result = TRUE;
            }
        } catch (Exception $ex) {
            //print $ex->getMessage();
        }
    }
    return $result;
}
开发者ID:ronniebrito,项目名称:moodle_moviemasher,代码行数:20,代码来源:s3utils.php


示例9: setAvatar

 public function setAvatar($userInfo, $source)
 {
     $registry = Zend_Registry::getInstance();
     $config = $registry->get("config");
     $people = Ml_Model_People::getInstance();
     $s3config = $config['services']['S3'];
     $s3 = new Zend_Service_Amazon_S3($s3config['key'], $s3config['secret']);
     try {
         $im = new Imagick($source);
         $im->setimagecompressionquality(self::$_imageQuality);
         $dim = $im->getimagegeometry();
         if (!$dim) {
             return false;
         }
     } catch (Exception $e) {
         return false;
     }
     $sizesInfo = array();
     $tmpFilenames = array();
     $im->unsharpMaskImage(0, 0.5, 1, 0.05);
     foreach ($this->_sizes as $sizeInfo) {
         $tmpFilenames[$sizeInfo[1]] = tempnam(sys_get_temp_dir(), 'HEADSHOT');
         if ($sizeInfo[0] == "sq") {
             if ($dim['height'] < $dim['width']) {
                 $size = $dim['height'];
             } else {
                 $size = $dim['width'];
             }
             //@todo let the user crop using Javascript, so he/she can set the offsets (default 0,0)
             $im->cropThumbnailImage($sizeInfo[3], $sizeInfo[3]);
         } else {
             if ($dim['width'] < $sizeInfo[3] && $dim['height'] < $sizeInfo[3] && $sizeInfo[2] != 'huge') {
                 copy($source, $tmpFilenames[$sizeInfo[1]]);
             } else {
                 if ($dim['width'] > $dim['height']) {
                     $im->resizeimage($sizeInfo[3], 0, Imagick::FILTER_LANCZOS, 1);
                 } else {
                     $im->resize(0, $sizeInfo[3], Imagick::FILTER_LANCZOS, 1);
                 }
             }
         }
         $im->writeimage($tmpFilenames[$sizeInfo[1]]);
         $imGeometry = $im->getimagegeometry();
         $sizesInfo[$sizeInfo[0]] = array("w" => $imGeometry['width'], "h" => $imGeometry['height']);
     }
     $oldData = unserialize($userInfo['avatarInfo']);
     //get the max value of mt_getrandmax() or the max value of the unsigned int type
     if (mt_getrandmax() < 4294967295.0) {
         $maxRand = mt_getrandmax();
     } else {
         $maxRand = 4294967295.0;
     }
     $newSecret = mt_rand(0, $maxRand);
     if (isset($oldData['secret'])) {
         while ($oldData['secret'] == $newSecret) {
             $newSecret = mt_rand(0, $maxRand);
         }
     }
     foreach ($tmpFilenames as $size => $file) {
         if ($size == '_h') {
             $privacy = Zend_Service_Amazon_S3::S3_ACL_PRIVATE;
         } else {
             $privacy = Zend_Service_Amazon_S3::S3_ACL_PUBLIC_READ;
         }
         $picAddr = $s3config['headshotsBucket'] . "/" . $userInfo['id'] . '-' . $newSecret . $size . '.jpg';
         $meta = array(Zend_Service_Amazon_S3::S3_ACL_HEADER => $privacy, "Content-Type" => Zend_Service_Amazon_S3::getMimeType($picAddr), "Cache-Control" => "max-age=37580000, public", "Expires" => "Thu, 10 May 2029 00:00:00 GMT");
         $s3->putFile($file, $picAddr, $meta);
         unlink($file);
     }
     $newAvatarInfo = serialize(array("sizes" => $sizesInfo, "secret" => $newSecret));
     $people->update($userInfo['id'], array("avatarInfo" => $newAvatarInfo));
     //delete the old files
     $this->deleteFiles($userInfo);
     return true;
 }
开发者ID:henvic,项目名称:MediaLab,代码行数:75,代码来源:Picture.php


示例10: tearDown

 /**
  * Tears down this test case
  *
  * @return void
  */
 public function tearDown()
 {
     if (!$this->_config) {
         return;
     }
     // Delete the bucket here
     $s3 = new Zend_Service_Amazon_S3($this->_config->get(Zend_Cloud_StorageService_Adapter_S3::AWS_ACCESS_KEY), $this->_config->get(Zend_Cloud_StorageService_Adapter_S3::AWS_SECRET_KEY));
     $s3->removeBucket($this->_config->get(Zend_Cloud_StorageService_Adapter_S3::BUCKET_NAME));
     parent::tearDown();
 }
开发者ID:jsnshrmn,项目名称:Suma,代码行数:15,代码来源:S3Test.php


示例11: uploadAction

 /**
  * Upload placeholders to CDN
  *
  * @return null
  */
 public function uploadAction()
 {
     $website = $this->getRequest()->getParam('website');
     $website = Mage::app()->getWebsite($website);
     if (!$website->getId()) {
         return $this->_back('No website parameter', self::ERROR, $website);
     }
     $store = $website->getDefaultStore();
     $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);
     Mage::log($dimensions);
     if (!($accessKey && $secretKey && $bucket && $prefix)) {
         return $this->_back('CDN settings are not specified', self::ERROR, $website);
     }
     unset($path);
     $config = Mage::getSingleton('catalog/product_media_config');
     $destSubdirs = array('image', 'small_image', 'thumbnail');
     $placeholders = array();
     $appEmulation = Mage::getModel('core/app_emulation');
     $env = $appEmulation->startEnvironmentEmulation($store->getId());
     foreach ($destSubdirs as $destSubdir) {
         $placeholder = Mage::getModel('catalog/product_image')->setDestinationSubdir($destSubdir)->setBaseFile(null)->getBaseFile();
         $basename = basename($placeholder);
         $result = copy($placeholder, $config->getMediaPath($basename));
         if ($result !== true) {
             return $this->_back('Error on copy ' . $placeholder . ' to media folder', self::ERROR, $website);
         }
         $placeholders[] = '/' . $basename;
     }
     $appEmulation->stopEnvironmentEmulation($env);
     unset($store);
     unset($appEmulation);
     $s3 = new Zend_Service_Amazon_S3($accessKey, $secretKey);
     $cdnPrefix = $bucket . '/' . $prefix . '/';
     $dimensions = str_replace(', ', ',', $dimensions);
     $dimensions = explode(',', $dimensions);
     $meta = array(Zend_Service_Amazon_S3::S3_ACL_HEADER => Zend_Service_Amazon_S3::S3_ACL_PUBLIC_READ);
     foreach ($placeholders as $fileName) {
         $cdnPath = $cdnPrefix . 'full' . $fileName;
         $file = $config->getMediaPath($fileName);
         try {
             $s3->putFile($file, $cdnPath, $meta);
         } catch (Exception $e) {
             return $this->_back($e->getMessage(), self::ERROR, $website);
         }
         if (!count($dimensions)) {
             continue;
         }
         foreach ($dimensions as $dimension) {
             $newCdnPath = $cdnPrefix . $dimension . $fileName;
             $productImage = Mage::getModel('catalog/product_image');
             $destinationSubdir = '';
             foreach ($destSubdirs as $destSubdir) {
                 $newFile = $productImage->setDestinationSubdir($destSubdir)->setSize($dimension)->setBaseFile($fileName)->getNewFile();
                 if (file_exists($newFile)) {
                     $destinationSubdir = $destSubdir;
                     break;
                 }
             }
             if ($destinationSubdir == '') {
                 try {
                     $newFile = $productImage->setDestinationSubdir($destinationSubdir)->setSize($dimension)->setBaseFile($fileName)->resize()->saveFile()->getNewFile();
                 } catch (Exception $e) {
                     return $this->_back($e->getMessage(), self::ERROR, $website);
                 }
             }
             try {
                 $s3->putFile($newFile, $newCdnPath, $meta);
             } catch (Exception $e) {
                 return $this->_back($e->getMessage(), self::ERROR, $website);
             }
         }
     }
     return $this->_back('Successfully uploaded all placeholders', self::SUCCESS, $website);
 }
开发者ID:sebastianwahn,项目名称:MVentory_S3CDN,代码行数:83,代码来源:PlaceholdersController.php


示例12: setMeta

 public function setMeta($userInfo, $shareInfo, $metaData, $errorHandle = false)
 {
     $config = self::$_registry->get("config");
     if ($userInfo['id'] != $shareInfo['byUid']) {
         throw new Exception("User is not the owner of the share.");
     }
     $changeData = array();
     if ($errorHandle) {
         foreach (self::$_editableMetadata as $what) {
             if (empty($errorHandle[$what]) && $metaData[$what] != $shareInfo[$what]) {
                 $changeData[$what] = $metaData[$what];
             }
         }
     } else {
         $changeData = $metaData;
     }
     if (empty($changeData)) {
         return false;
     }
     if (isset($changeData['filename'])) {
         $s3 = new Zend_Service_Amazon_S3($config['services']['S3']['key'], $config['services']['S3']['secret']);
         $bucketPlusObjectKeyPrefix = $config['services']['S3']['sharesBucket'] . "/" . $userInfo['alias'] . "/" . $shareInfo['id'] . "-" . $shareInfo['download_secret'] . "/";
         $source = $bucketPlusObjectKeyPrefix . $shareInfo['filename'];
         $destination = $bucketPlusObjectKeyPrefix . $changeData['filename'];
         $meta = array(Zend_Service_Amazon_S3::S3_ACL_HEADER => Zend_Service_Amazon_S3::S3_ACL_PUBLIC_READ, "x-amz-copy-source" => $source, "x-amz-metadata-directive" => "COPY");
         $request = $s3->_makeRequest("PUT", $destination, null, $meta);
         if ($request->getStatus() == 200) {
             $filenameChanged = true;
         }
     }
     if (isset($filenameChanged) && $filenameChanged) {
         $removeFiles = Ml_Model_RemoveFiles::getInstance();
         $removeFiles->addFileGc(array("share" => $shareInfo['id'], "byUid" => $shareInfo['byUid'], "download_secret" => $shareInfo['download_secret'], "filename" => $shareInfo['filename'], "alias" => $userInfo['alias']));
         //Using delete from the S3 Zend class here doesn't work because of a bug
         //is not working for some reason after the _makeRequest or other things I tried to COPY...
     } else {
         unset($changeData['filename']);
     }
     if (empty($changeData)) {
         return false;
     }
     if (isset($changeData['description'])) {
         $purifier = Ml_Model_HtmlPurifier::getInstance();
         $changeData['description_filtered'] = $purifier->purify($changeData['description']);
     }
     $date = new Zend_Date();
     $changeData['lastChange'] = $date->get("yyyy-MM-dd HH:mm:ss");
     $this->_dbTable->update($changeData, $this->_dbAdapter->quoteInto("id = ?", $shareInfo['id']));
     return array_merge($shareInfo, $changeData);
 }
开发者ID:henvic,项目名称:MediaLab,代码行数:50,代码来源:Share.php


示例13: 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


示例14: printLog

            if ($wp_blog_tables = $db->fetchCol('SHOW TABLES FROM `' . WORDPRESS_MULTISITE_DB_NAME . '` LIKE "' . $wp_table_prefix . '_' . $wp_blog_id . '%"')) {
                $file_name = 'wordpress_' . $wp_blog_domain . '.sql' . (GZIP_DUMP_FILES ? '.gz' : '');
                printLog('Dumping database tables for the wordpress site ' . $wp_blog_domain);
                mysqldump(WORDPRESS_MULTISITE_DB_NAME, $file_name, $wp_blog_tables);
                $dumps[] = $file_name;
            }
        }
        if ($wp_main_tables = $db->fetchCol('SHOW TABLES FROM `' . WORDPRESS_MULTISITE_DB_NAME . '` WHERE Tables_in_' . WORDPRESS_MULTISITE_DB_NAME . ' REGEXP "' . $wp_table_prefix . '_[a-z]"')) {
            $file_name = 'wordpress.sql' . (GZIP_DUMP_FILES ? '.gz' : '');
            printLog('Dumping database tables for the wordpress core');
            mysqldump(WORDPRESS_MULTISITE_DB_NAME, $file_name, $wp_main_tables);
            $dumps[] = $file_name;
        }
    }
    if (UPLOAD_TO_AWS) {
        $s3 = new Zend_Service_Amazon_S3(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY);
        foreach ($dumps as $dump) {
            $file_contents = file_get_contents(DUMPS_PATH . '/' . $dump);
            printLog('Uploading ' . $dump . ' to the Amazon S3 storage');
            $upload_succesful = $s3->putObject(AWS_BUCKET_NAME . '/' . $timestamp . '/' . $dump, $file_contents);
            if (DELETE_AFTER_UPLOAD && $upload_succesful === true) {
                printLog('Deleting ' . $dump . ' from the local file system');
                unlink(DUMPS_PATH . '/' . $dump);
            }
        }
        if (DELETE_AFTER_UPLOAD) {
            rmdir(DUMPS_PATH);
        }
    }
} catch (Exception $e) {
    printLog($e->getMessage());
开发者ID:jonathanp,项目名称:mysql-db-backup,代码行数:31,代码来源:backup_databases.php


示例15: 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;
 }
开发者ID:CivicCommons,项目名称:people-aggregator,代码行数:44,代码来源:EditProfileModule.php


示例16: moveDumpToS3

 /**
  * Move the dump file to a Amazon S3 bucket
  *
  * @param string $filename
  * @return void
  */
 protected function moveDumpToS3($filename)
 {
     $s3Config = $this->config->s3;
     $this->validateS3Settings($s3Config);
     $s3File = $s3Config->aws_bucket . '/' . $filename;
     $this->writer->line('Copy ' . $filename . ' -> Amazon S3: ' . $s3File);
     $s3 = new Zend_Service_Amazon_S3($s3Config->aws_key, $s3Config->aws_secret_key);
     // use https for uploading
     $s3->setEndpoint('https://' . Zend_Service_Amazon_S3::S3_ENDPOINT);
     $s3->putObject($s3Config->aws_bucket . '/' . $filename, file_get_contents($filename));
     $s3->getObject($s3Config->aws_bucket . '/' . $filename);
 }
开发者ID:rosstuck,项目名称:DbPatch,代码行数:18,代码来源:Dump.php


示例17: str_replace

 $cdnPrefix = $bucket . '/' . $prefix . '/';
 $dimensions = str_replace(', ', ',', $dimensions);
 $dimensions = explode(',', $dimensions);
 $meta = array(Zend_Service_Amazon_S3::S3_ACL_HEADER => Zend_Service_Amazon_S3::S3_ACL_PUBLIC_READ);
 $config = Mage::getSingleton('catalog/product_media_config');
 $destSubdirs = array('image', 'small_image', 'thumbnail');
 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');
开发者ID:sebastianwahn,项目名称:MVentory_S3CDN,代码行数:31,代码来源:upload-to-s3.php


示例18: tearDown

 public function tearDown()
 {
     unset($this->_amazon->debug);
     $this->_amazon->cleanBucket($this->_bucket);
     $this->_amazon->removeBucket($this->_bucket);
     sleep(1);
 }
开发者ID:jsnshrmn,项目名称:Suma,代码行数:7,代码来源:OnlineTest.php


示例19: stream_stat

 /**
  * Returns data array of stream variables
  *
  * @return array
  */
 public function stream_stat()
 {
     if (!$this->_objectName) {
         return false;
     }
     $stat = array();
     $stat['dev'] = 0;
     $stat['ino'] = 0;
     $stat['mode'] = 0;
     $stat['nlink'] = 0;
     $stat['uid'] = 0;
     $stat['gid'] = 0;
     $stat['rdev'] = 0;
     $stat['size'] = 0;
     $stat['atime'] = 0;
     $stat['mtime'] = 0;
     $stat['ctime'] = 0;
     $stat['blksize'] = 0;
     $stat['blocks'] = 0;
     $info = $this->_s3->getInfo($this->_objectName);
     if (!empty($info)) {
         $stat['size'] = $info['size'];
         $stat['atime'] = time();
         $stat['mtime'] = $info['mtime'];
     }
     return $stat;
 }
开发者ID:AholibamaSI,项目名称:plymouth-webapp,代码行数:32,代码来源:Stream.php


示例20: stream_stat

 /**
  * Returns data array of stream variables
  *
  * @return array
  */
 public function stream_stat()
 {
     if (!$this->_objectName) {
         return false;
     }
     $stat = array();
     $stat['dev'] = 0;
     $stat['ino'] = 0;
     $stat['mode'] = 0777;
     $stat['nlink'] = 0;
     $stat['uid'] = 0;
     $stat['gid'] = 0;
     $stat['rdev'] = 0;
     $stat['size'] = 0;
     $stat['atime'] = 0;
     $stat['mtime'] = 0;
     $stat['ctime'] = 0;
     $stat['blksize'] = 0;
     $stat['blocks'] = 0;
     if (($slash = strchr($this->_objectName, '/')) === false || $slash == strlen($this->_objectName) - 1) {
         /* bucket */
         $stat['mode'] |= 040000;
     } else {
         $stat['mode'] |= 0100000;
     }
     $info = $this->_s3->getInfo($this->_objectName);
     if (!empty($info)) {
         $stat['size'] = $info['size'];
         $stat['atime'] = time();
         $stat['mtime'] = $info['mtime'];
     }
     return $stat;
 }
开发者ID:fredcido,项目名称:simuweb,代码行数:38,代码来源:Stream.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Zend_Service_Delicious类代码示例发布时间:2022-05-23
下一篇:
PHP Zend_Service_Amazon_Abstract类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap