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


PHP RequestCore::send_multi_request方法代码示例

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


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

示例1: copy_object


//.........这里部分代码省略.........
  * 	public
  *
  * Parameters:
  * 	$source - _array_ (Required) An associative array containing two keys: `bucket`, specifying the name of the bucket containing the source object, and `filename`, specifying the file name of the source object to copy.
  * 	$dest - _array_ (Required) An associative array containing two keys: `bucket`, specifying the name of the bucket to store the destination object in, and `filename`, specifying the file name of the destination object name.
  * 	$opt - _array_ (Optional) An associative array of parameters that can have the keys listed in the following section.
  *
  * Keys for the $opt parameter:
  * 	acl - _string_ (Optional) The ACL settings for the specified object. [Allowed values: `AmazonS3::ACL_PRIVATE`, `AmazonS3::ACL_PUBLIC`, `AmazonS3::ACL_OPEN`, `AmazonS3::ACL_AUTH_READ`, `AmazonS3::ACL_OWNER_READ`, `AmazonS3::ACL_OWNER_FULL_CONTROL`]. Alternatively, an array of associative arrays. Each associative array contains an `id` and a `permission` key. The default value is <ACL_PRIVATE>.
  * 	storage - _string_ (Optional) Whether to use Standard or Reduced Redundancy storage. [Allowed values: `AmazonS3::STORAGE_STANDARD`, `AmazonS3::STORAGE_REDUCED`]. The default value is <STORAGE_STANDARD>.
  * 	versionId - _string_ (Optional) The version of the object to copy. Version IDs are returned in the `x-amz-version-id` header of any previous object-related request.
  * 	ifMatch - _string_ (Optional) The ETag header from a previous request. Copies the object if its entity tag (ETag) matches the specified tag; otherwise, the request returns a `412` HTTP status code error (precondition failed). Used in conjunction with `ifUnmodifiedSince`.
  * 	ifUnmodifiedSince - _string_ (Optional) The LastModified header from a previous request. Copies the object if it hasn't been modified since the specified time; otherwise, the request returns a `412` HTTP status code error (precondition failed). Used in conjunction with `ifMatch`.
  * 	ifNoneMatch - _string_ (Optional) The ETag header from a previous request. Copies the object if its entity tag (ETag) is different than the specified ETag; otherwise, the request returns a `412` HTTP status code error (failed condition). Used in conjunction with `ifModifiedSince`.
  * 	ifModifiedSince - _string_ (Optional) The LastModified header from a previous request. Copies the object if it has been modified since the specified time; otherwise, the request returns a `412` HTTP status code error (failed condition). Used in conjunction with `ifNoneMatch`.
  * 	headers - _array_ (Optional) Standard HTTP headers to send along in the request.
  * 	meta - _array_ (Optional) Associative array of key-value pairs. Represented by `x-amz-meta-:` Any header starting with this prefix is considered user metadata. It will be stored with the object and returned when you retrieve the object. The total size of the HTTP request, not including the body, must be less than 4 KB.
  * 	metadataDirective - _string_ (Optional) Accepts either COPY or REPLACE. You will likely never need to use this, as it manages itself with no issues.
  * 	returnCurlHandle - _boolean_ (Optional) A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.
  *
  * Returns:
  * 	_CFResponse_ A <CFResponse> object containing a parsed HTTP response.
  *
  * See Also:
  * 	[Copying Amazon S3 Objects](http://docs.amazonwebservices.com/AmazonS3/latest/UsingCopyingObjects.html)
  */
 public function copy_object($source, $dest, $opt = null)
 {
     if (!$opt) {
         $opt = array();
     }
     $batch = array();
     // Add this to our request
     $opt['verb'] = 'PUT';
     $opt['resource'] = $dest['filename'];
     // Handle copy source
     if (isset($source['bucket']) && isset($source['filename'])) {
         $opt['headers']['x-amz-copy-source'] = '/' . $source['bucket'] . '/' . rawurlencode($source['filename']) . (isset($opt['versionId']) ? '?' . 'versionId=' . rawurlencode($opt['versionId']) : '');
         // Append the versionId to copy, if available
         unset($opt['versionId']);
         // Determine if we need to lookup the pre-existing content-type.
         if (!in_array(strtolower('content-type'), array_map('strtolower', array_keys($opt['headers'])))) {
             $response = $this->get_object_headers($source['bucket'], $source['filename']);
             $opt['headers']['Content-Type'] = $response->header['content-type'];
         }
     }
     // Handle metadata directive
     $opt['headers']['x-amz-metadata-directive'] = 'COPY';
     if ($source['bucket'] === $dest['bucket'] && $source['filename'] === $dest['filename']) {
         $opt['headers']['x-amz-metadata-directive'] = 'REPLACE';
     }
     if (isset($opt['metadataDirective'])) {
         $opt['headers']['x-amz-metadata-directive'] = $opt['metadataDirective'];
         unset($opt['metadataDirective']);
     }
     // Handle Access Control Lists. Can also pass canned ACLs as an HTTP header.
     if (isset($opt['acl']) && is_array($opt['acl'])) {
         $batch[] = $this->set_object_acl($dest['bucket'], $dest['filename'], $opt['acl'], array('returnCurlHandle' => true));
         unset($opt['acl']);
     } elseif (isset($opt['acl'])) {
         $opt['headers']['x-amz-acl'] = $opt['acl'];
         unset($opt['acl']);
     }
     // Handle storage settings. Can also be passed as an HTTP header.
     if (isset($opt['storage'])) {
         $opt['headers']['x-amz-storage-class'] = $opt['storage'];
         unset($opt['storage']);
     }
     // Handle conditional-copy parameters
     if (isset($opt['ifMatch'])) {
         $opt['headers']['x-amz-copy-source-if-match'] = $opt['ifMatch'];
         unset($opt['ifMatch']);
     }
     if (isset($opt['ifNoneMatch'])) {
         $opt['headers']['x-amz-copy-source-if-none-match'] = $opt['ifNoneMatch'];
         unset($opt['ifNoneMatch']);
     }
     if (isset($opt['ifUnmodifiedSince'])) {
         $opt['headers']['x-amz-copy-source-if-unmodified-since'] = $opt['ifUnmodifiedSince'];
         unset($opt['ifUnmodifiedSince']);
     }
     if (isset($opt['ifModifiedSince'])) {
         $opt['headers']['x-amz-copy-source-if-modified-since'] = $opt['ifModifiedSince'];
         unset($opt['ifModifiedSince']);
     }
     // Handle meta tags. Can also be passed as an HTTP header.
     if (isset($opt['meta'])) {
         foreach ($opt['meta'] as $meta_key => $meta_value) {
             // e.g., `My Meta Header` is converted to `x-amz-meta-my-meta-header`.
             $opt['headers']['x-amz-meta-' . strtolower(str_replace(' ', '-', $meta_key))] = $meta_value;
         }
         unset($opt['meta']);
     }
     // Authenticate to S3
     $response = $this->authenticate($dest['bucket'], $opt);
     // Attempt to reset ACLs
     $http = new RequestCore();
     $http->send_multi_request($batch);
     return $response;
 }
开发者ID:Webbiker,项目名称:Klompenschuurtje,代码行数:101,代码来源:s3.class.php


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