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


PHP AmazonS3::copy_object方法代码示例

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


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

示例1: moveObject

 /**
  * Move a file or folder to a specific location
  *
  * @param string $from The location to move from
  * @param string $to The location to move to
  * @param string $point
  * @return boolean
  */
 public function moveObject($from, $to, $point = 'append')
 {
     $this->xpdo->lexicon->load('source');
     $success = false;
     if (substr(strrev($from), 0, 1) == '/') {
         $this->xpdo->error->message = $this->xpdo->lexicon('s3_no_move_folder', array('from' => $from));
         return $success;
     }
     if (!$this->driver->if_object_exists($this->bucket, $from)) {
         $this->xpdo->error->message = $this->xpdo->lexicon('file_err_ns') . ': ' . $from;
         return $success;
     }
     if ($to != '/') {
         if (!$this->driver->if_object_exists($this->bucket, $to)) {
             $this->xpdo->error->message = $this->xpdo->lexicon('file_err_ns') . ': ' . $to;
             return $success;
         }
         $toPath = rtrim($to, '/') . '/' . basename($from);
     } else {
         $toPath = basename($from);
     }
     $response = $this->driver->copy_object(array('bucket' => $this->bucket, 'filename' => $from), array('bucket' => $this->bucket, 'filename' => $toPath), array('acl' => AmazonS3::ACL_PUBLIC));
     $success = $response->isOK();
     if ($success) {
         $deleteResponse = $this->driver->delete_object($this->bucket, $from);
         $success = $deleteResponse->isOK();
     } else {
         $this->xpdo->error->message = $this->xpdo->lexicon('file_folder_err_rename') . ': ' . $to . ' -> ' . $from;
     }
     return $success;
 }
开发者ID:nervlin4444,项目名称:modx-cms,代码行数:39,代码来源:mods3mediasource.class.php

示例2: rename

 /**
  * rename file/directory
  *
  * @return string
  */
 public function rename()
 {
     $oldPath = $this->sanitizePath($this->get['old']);
     $isDir = $this->isDir($this->metadata("{$oldPath}/"));
     $oldPath .= $isDir ? '/' : '';
     $contents = $isDir ? $this->s3->get_object_list($this->bucket, array('prefix' => $oldPath)) : array();
     // NOTE: we do this instead of isDir as we only care if there are files under this prefix
     if (count($contents) > 1) {
         $this->error('Unfortunately, we are currently unable to rename a non-empty directory.', false);
     }
     $pathInfo = pathinfo($oldPath);
     $dirName = $pathInfo['dirname'];
     $baseName = $pathInfo['basename'];
     $newFile = $this->get['new'];
     $newPath = join('/', array($dirName, $newFile));
     if ($isDir) {
         $response = $this->createDirectory($newPath);
     } else {
         $response = $this->s3->copy_object(array('bucket' => $this->bucket, 'filename' => $oldPath), array('bucket' => $this->bucket, 'filename' => $newPath), array('acl' => AmazonS3::ACL_PUBLIC));
     }
     if ($response->isOK()) {
         $this->s3->delete_object($this->bucket, $oldPath);
     }
     return array('Error' => '', 'Code' => 0, 'Old Path' => $oldPath, 'Old Name' => $baseName, 'New Path' => $newPath, 'New Name' => $newFile);
 }
开发者ID:lucasmilin,项目名称:filemanager-php-s3-plugin,代码行数:30,代码来源:filemanager.s3.class.php

示例3: printf

    exit;
}
$mime = NULL;
$response = $s3->get_object_metadata($bucket, $name);
//get content-type of existing object
if ($response) {
    $mime = $response["ContentType"];
}
if (empty($mime)) {
    printf("No mime found for object \n");
    exit;
}
$source = array("bucket" => $bucket, "filename" => $name);
$dest = array("bucket" => $bucket, "filename" => $name);
// caching headers
// expire after 365 days
$offset = 3600 * 24 * 365;
$expiresOn = gmdate('D, d M Y H:i:s \\G\\M\\T', time() + $offset);
$headers = array();
$headers["Expires"] = $expiresOn;
$headers["Cache-Control"] = "public, max-age=31536000";
$headers["Content-Type"] = $mime;
// This will overwrite existing headers
$meta = array('acl' => AmazonS3::ACL_PUBLIC, 'headers' => $headers);
$response = $s3->copy_object($source, $dest, $meta);
if ($response->isOk()) {
    printf("s3 object copy done \n");
} else {
    printf("Error :: s3 object copy \n");
    exit;
}
开发者ID:rjha,项目名称:sc,代码行数:31,代码来源:s3-caching-headers.php

示例4: array

 */
require_once "sdk-1.5.7/sdk.class.php";
error_reporting(-1);
$config = parse_ini_file("aws.ini");
$awsKey = $config["aws.key"];
$awsSecret = $config["aws.secret"];
$options = array("key" => $awsKey, "secret" => $awsSecret, "default_cache_config" => '', "certificate_authority" => true);
$s3 = new AmazonS3($options);
$source = "test.indigloo";
$target = "rjha";
$name = "polaroid.swf";
$exists = $s3->if_bucket_exists($source);
if (!$exists) {
    $message = sprintf("source bucket %s does not exists", $source);
    printf("%s \n", $message);
    exit;
}
$exists = $s3->if_bucket_exists($target);
if (!$exists) {
    $message = sprintf("target bucket %s does not exists", $source);
    printf("%s \n", $message);
    exit;
}
$source = array("bucket" => $source, "filename" => $name);
$dest = array("bucket" => $target, "filename" => $name);
$response = $s3->copy_object($source, $dest);
if ($response->isOk()) {
    printf("s3 object copy done \n");
} else {
    printf("Error :: s3 object copy \n");
}
开发者ID:rjha,项目名称:sc,代码行数:31,代码来源:s3-copy-object.php


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