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


PHP Zend_Service_Amazon_S3::putObject方法代码示例

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


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

示例1: _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

示例2: storeItem

 /**
  * Store an item in the storage service.
  *
  * WARNING: This operation overwrites any item that is located at
  * $destinationPath.
  *
  * @TODO Support streams
  *
  * @param string $destinationPath
  * @param string|resource $data
  * @param  array $options
  * @return void
  */
 public function storeItem($destinationPath, $data, $options = array())
 {
     try {
         $fullPath = $this->_getFullPath($destinationPath, $options);
         return $this->_s3->putObject($fullPath, $data, empty($options[self::METADATA]) ? null : $options[self::METADATA]);
     } catch (Zend_Service_Amazon_S3_Exception $e) {
         throw new Zend_Cloud_StorageService_Exception('Error on store: ' . $e->getMessage(), $e->getCode(), $e);
     }
 }
开发者ID:laiello,项目名称:vinhloi,代码行数:22,代码来源:S3.php

示例3: testCommonPrefixes

 public function testCommonPrefixes()
 {
     $this->_amazon->createBucket($this->_bucket);
     $this->_amazon->putObject($this->_bucket . '/test-folder/test1', 'test');
     $this->_amazon->putObject($this->_bucket . '/test-folder/test2-folder/', '');
     $params = array('prefix' => 'test-folder/', 'delimiter' => '/');
     $response = $this->_amazon->getObjectsAndPrefixesByBucket($this->_bucket, $params);
     $this->assertEquals($response['objects'][0], 'test-folder/test1');
     $this->assertEquals($response['prefixes'][0], 'test-folder/test2-folder/');
 }
开发者ID:navassouza,项目名称:zf2,代码行数:10,代码来源:OnlineTest.php

示例4: stream_flush

 /**
  * Flush current cached stream data to storage
  *
  * @return boolean
  */
 public function stream_flush()
 {
     // If the stream wasn't opened for writing, just return false
     if (!$this->_writeBuffer) {
         return false;
     }
     $ret = $this->_s3->putObject($this->_objectName, $this->_objectBuffer);
     $this->_objectBuffer = null;
     return $ret;
 }
开发者ID:fredcido,项目名称:simuweb,代码行数:15,代码来源:Stream.php

示例5: testGetObjectsByBucketParams

 /**
  *  @see 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");
 }
开发者ID:vicfryzel,项目名称:zf,代码行数:14,代码来源:OnlineTest.php

示例6: write

 /**
  * Creates a new file from data rather than an existing file
  *
  * @param Storage_Model_DbRow_File $model The file for operation
  * @param string $data
  */
 public function write(Storage_Model_File $model, $data)
 {
     $path = $this->getScheme()->generate($model->toArray());
     // Prefix path with bucket?
     //$path = $this->_bucket . '/' . $path;
     // Copy file
     try {
         $return = $this->_internalService->putObject($this->_bucket . '/' . $path, $data, array(Zend_Service_Amazon_S3::S3_ACL_HEADER => Zend_Service_Amazon_S3::S3_ACL_PUBLIC_READ, 'Cache-Control' => 'max-age=864000, public'));
         if (!$return) {
             throw new Storage_Service_Exception('Unable to write file.');
         }
     } catch (Exception $e) {
         throw $e;
     }
     return $path;
 }
开发者ID:febryantosulistyo,项目名称:ClassicSocial,代码行数:22,代码来源:S3.php

示例7: s3_put_data

function s3_put_data($access_key_id, $secret_access_key, $bucket_path, $data, $mime)
{
    $result = FALSE;
    if ($access_key_id && $secret_access_key && $bucket_path && $data) {
        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->putObject($bucket_path, $data, $meta)) {
                $result = TRUE;
            } else {
                print 'putObject failed';
            }
        } catch (Exception $ex) {
            print $ex->getMessage();
        }
    }
    return $result;
}
开发者ID:ronniebrito,项目名称:moodle_moviemasher,代码行数:22,代码来源:s3utils.php

示例8: store

 /**
  * @param string $filename
  * @param string $data               Binary file data
  * @param boolean $overwrite         Whether to overwrite this file, or create a unique name
  * @param boolean $formatFilename    Whether to correct the filename,
  *                                   f.i. ensuring lowercase characters.
  * @return string                    Destination filename.
  */
 public function store($filename, $data, $overwrite = false, $formatFilename = true)
 {
     $this->_initApi();
     $this->_createBucketIfNecessary();
     if ($formatFilename) {
         $filename = Garp_File::formatFilename($filename);
     }
     if (!$overwrite) {
         while ($this->exists($filename)) {
             $filename = Garp_File::getCumulativeFilename($filename);
         }
     }
     $path = $this->_config['bucket'] . $this->_getUri($filename);
     $meta = array(Zend_Service_Amazon_S3::S3_ACL_HEADER => Zend_Service_Amazon_S3::S3_ACL_PUBLIC_READ);
     if (false !== strpos($filename, '.')) {
         $ext = substr($filename, strrpos($filename, '.') + 1);
         if (array_key_exists($ext, $this->_knownMimeTypes)) {
             $mime = $this->_knownMimeTypes[$ext];
         } else {
             $finfo = new finfo(FILEINFO_MIME);
             $mime = $finfo->buffer($data);
         }
     } else {
         $finfo = new finfo(FILEINFO_MIME);
         $mime = $finfo->buffer($data);
     }
     $meta[Zend_Service_Amazon_S3::S3_CONTENT_TYPE_HEADER] = $mime;
     if ($this->_config['gzip'] && $this->_gzipIsAllowedForFilename($filename)) {
         $meta['Content-Encoding'] = 'gzip';
         $data = gzencode($data);
     }
     if ($this->_api->putObject($path, $data, $meta)) {
         return $filename;
     }
     return false;
 }
开发者ID:grrr-amsterdam,项目名称:garp3,代码行数:44,代码来源:S3.php

示例9: basicProfileSave


//.........这里部分代码省略.........
                         $file_path = $zendUploadAdapter->getFileName('userfile', true);
                         $file_name = $zendUploadAdapter->getFileName('userfile', false);
                         $file_size = $zendUploadAdapter->getFileSize('userfile');
                         $file_name = $this->cleanupFileName($file_name);
                         $file_info = getimagesize($file_path);
                         $file_mime_type = isset($file_info) && isset($file_info['mime']) && !empty($file_info['mime']) ? $file_info['mime'] : null;
                         $apiDataArray['person'] = array('avatar' => array('file_name' => $file_name, 'content_type' => $file_mime_type, 'file_size' => $file_size));
                         // api_call needs to be set to true in order for the User class to update the avatar and avatar_small fields
                         $this->user_info->api_call = true;
                         foreach ($this->_image_sizes as $imageSizeType => $imageDimensions) {
                             // Resize image into thumbnails
                             $imageAsString = null;
                             try {
                                 $thumb = PhpThumbFactory::create($file_path);
                                 if (!isset($this->user_info->core_id) && !empty($this->user_info->core_id)) {
                                     $this->user_info->core_id = 0;
                                 }
                                 $objectPath = $this->buildAmazonS3ObjectURL($imageSizeType, $this->user_info->core_id, $file_name);
                                 if (isset($imageDimensions) && !empty($imageDimensions)) {
                                     // if this is an original size image, the width and height dont need to be set
                                     $thumb->adaptiveResize($imageDimensions['width'], $imageDimensions['height']);
                                 }
                                 $imageAsString = $thumb->getImageAsString();
                                 $amazonURL = "http://s3.amazonaws.com/" . $amazon_bucket_name;
                                 switch ($imageSizeType) {
                                     case "large":
                                         $this->user_info->picture = $objectPath;
                                         $this->user_info->picture_dimensions = $imageDimensions;
                                         break;
                                     case "standard":
                                         $this->user_info->avatar = $objectPath;
                                         $this->user_info->avatar_dimensions = $imageDimensions;
                                         break;
                                     case "medium":
                                         $this->user_info->avatar_small = $objectPath;
                                         $this->user_info->avatar_small_dimensions = $imageDimensions;
                                         break;
                                     default:
                                         break;
                                 }
                             } catch (Exception $e) {
                                 $this->message = $e->getMessage();
                                 break;
                             }
                             if (isset($imageAsString) && !empty($imageAsString)) {
                                 // send object to AmazonS3
                                 $s3->putObject($amazon_bucket_name . $objectPath, $imageAsString, array(Zend_Service_Amazon_S3::S3_ACL_HEADER => Zend_Service_Amazon_S3::S3_ACL_PUBLIC_READ));
                             }
                         }
                     }
                 }
             }
         }
     }
     if (empty($this->message)) {
         // Add first name and last name if they have been changed to the api update data array
         if ($this->user_info->first_name != $request_data['first_name'] || $this->user_info->last_name != $request_data['last_name']) {
             $apiDataArray['person']['name'] = $request_data['first_name'] . ' ' . $request_data['last_name'];
         }
         //If there is no error message then try saving the user information.
         $this->user_info->first_name = $request_data['first_name'];
         $this->user_info->last_name = $request_data['last_name'];
         try {
             if (!empty($request_data['pass'])) {
                 $passwordSaltArray = $this->EncryptPassword($request_data['pass']);
                 if (isset($passwordSaltArray)) {
                     list($encryptedPassword, $salt) = $passwordSaltArray;
                     $this->user_info->password = $encryptedPassword;
                     $apiDataArray['person']['encrypted_password'] = $encryptedPassword;
                     // remove last $ from salt because ruby doesn't like it
                     $salt = rtrim($salt, '$');
                     $apiDataArray['person']['password_salt'] = $salt;
                 } else {
                     $this->message = "Your password could not be changed, please contact the administrator.";
                 }
             }
         } catch (Exception $e) {
             $this->message = $e->getMessage();
         }
     }
     if (empty($this->message)) {
         try {
             $this->user_info->save();
             $dynProf = new DynamicProfile($this->user_info);
             $dynProf->processPOST('basic');
             $dynProf->save('basic', GENERAL);
             $this->message = __('Profile updated successfully.');
             //        $this->redirect2 = PA_ROUTE_EDIT_PROFILE;
             //        $this->queryString = '?type='.$this->profile_type;
             //TODO: change URL after the contributions activity stream URLs have been changed
             $url = CC_APPLICATION_URL . CC_APPLICATION_URL_TO_API . $this->user_info->user_id;
             // Try to send updated data to Core (Ruby)
             $this->sendUserDataToCivicCommons($url, $apiDataArray);
             $this->isError = FALSE;
         } catch (PAException $e) {
             $this->message = $e->message;
         }
     }
     $error_msg = $this->message;
 }
开发者ID:CivicCommons,项目名称:people-aggregator,代码行数:101,代码来源:EditProfileModule.php

示例10: mysqldump

                $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());
}
function mysqldump($db_name, $file_name, $tables = null)
{
    $mysqldump = sprintf('%s "%s" -u %s --password=%s', MYSQLDUMP, $db_name, DB_USERNAME, DB_PASSWORD);
开发者ID:jonathanp,项目名称:mysql-db-backup,代码行数:31,代码来源:backup_databases.php

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


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