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


PHP S3::copyObject方法代码示例

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


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

示例1: copyTransform

 /**
  * Copy a transform for a file from source location to target location.
  *
  * @param AssetFileModel $file
  * @param $source
  * @param $target
  * @return mixed
  */
 public function copyTransform(AssetFileModel $file, $source, $target)
 {
     $this->_prepareForRequests();
     $basePath = $this->_getPathPrefix() . $file->getFolder()->fullPath;
     $bucket = $this->getSettings()->bucket;
     @$this->_s3->copyObject($bucket, $basePath . $source . '/' . $file->filename, $bucket, $basePath . $target . '/' . $file->filename, \S3::ACL_PUBLIC_READ);
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:15,代码来源:S3AssetSourceType.php

示例2: copySourceFile

 /**
  * @inheritDoc BaseAssetSourceType::copySourceFile()
  *
  * @param $sourceUri
  * @param $targetUri
  *
  * @return bool
  */
 protected function copySourceFile($sourceUri, $targetUri)
 {
     if ($sourceUri == $targetUri) {
         return true;
     }
     $bucket = $this->getSettings()->bucket;
     return (bool) @$this->_s3->copyObject($bucket, $sourceUri, $bucket, $targetUri, $this->_getACL());
 }
开发者ID:JamesGibsonUK,项目名称:gibsonlearn,代码行数:16,代码来源:S3AssetSourceType.php

示例3: execute

 public function execute()
 {
     $this->AWS_ACCESS_KEY = 'YOUR_AWS_ACCESS_KEY';
     $this->AWS_SECRET_KEY = 'YOUR_AWS_SECRET_KEY';
     $this->AWS_S3_BUCKET = 'YOUR_AWS_S3_BUCKET';
     $this->AWS_S3_PUBLIC = true;
     $this->AWS_S3_SSL = false;
     $s3 = new S3();
     $s3->setAuth($this->AWS_ACCESS_KEY, $this->AWS_SECRET_KEY);
     $s3->useSSL = $this->AWS_S3_SSL;
     // In my situation the images were in two different S3 buckets already. It will search these locations to try and find it.
     // Your images are probably local already, so you may need to modify the code further down to work with local directories.
     //$s3Buckets = array(...);
     $dbw = wfGetDB(DB_MASTER);
     $counter = 0;
     $iIncrement = 10000;
     for ($i = 0;; $i += $iIncrement) {
         $res = $dbw->select(array('image', 'imagelinks', 'page'), array('image.img_name', 'image.img_path', 'page.page_title'), 'image.img_name = imagelinks.il_to and imagelinks.il_from = page.page_id and page.page_namespace = 0 limit ' . $i . ', ' . $iIncrement, array());
         if (!$res) {
             echo 'No for rows.\\n';
             exit;
         }
         $logoPath = '';
         foreach ($res as $row) {
             echo "counter:{$counter}\n";
             echo "i:{$i}\n";
             ++$counter;
             if (!$row->img_name || !$row->img_path) {
                 continue;
             }
             echo 'img_name:' . $row->img_name . "\n";
             echo 'img_path:' . $row->img_path . "\n";
             echo 'page_title:' . $row->page_title . "\n";
             $file = wfFindFile($row->img_name, array());
             if ($file) {
                 $path = $file->getFullUrl();
                 $path = str_replace('http://s3.amazonaws.com/' . $this->AWS_S3_BUCKET . '/', '', $path);
                 echo "path:{$path}\n";
                 // If you have images that are already stored locally, you will need to modify this section. Instead of an S3::copyObject you
                 // may need to use the S3::putObject method to upload your local copy.
                 foreach ($s3Buckets as $s3Bucket) {
                     if ($s3->copyObject($s3Bucket, $row->img_path, $this->AWS_S3_BUCKET, $path, $this->AWS_S3_PUBLIC ? S3::ACL_PUBLIC_READ : S3::ACL_PRIVATE)) {
                         echo 'SUCCESS:' . $row->img_name . "\n";
                         break;
                     } else {
                         echo 'ERROR1:' . $row->img_name . "\n";
                     }
                 }
             } else {
                 echo 'ERROR2:' . $row->img_name . "\n";
             }
             echo "\n";
         }
     }
 }
开发者ID:robksawyer,项目名称:lathe.tools,代码行数:55,代码来源:currentImagesToS3Migration.php

示例4: duplicateFile

 public static function duplicateFile($storageFileID, $newName, $zip, $contentType = null)
 {
     self::requireLibrary();
     if (!$newName) {
         throw new Exception("New name not provided");
     }
     $localInfo = self::getFileInfoByID($storageFileID);
     if (!$localInfo) {
         throw new Exception("File {$storageFileID} not found");
     }
     S3::setAuth(Z_CONFIG::$S3_ACCESS_KEY, Z_CONFIG::$S3_SECRET_KEY);
     $success = S3::copyObject(Z_CONFIG::$S3_BUCKET, self::getPathPrefix($localInfo['hash'], $localInfo['zip']) . $localInfo['filename'], Z_CONFIG::$S3_BUCKET, self::getPathPrefix($localInfo['hash'], $zip) . $newName, S3::ACL_PRIVATE, array(), $contentType ? array("Content-Type" => $contentType) : array());
     if (!$success) {
         return false;
     }
     $info = new Zotero_StorageFileInfo();
     foreach ($localInfo as $key => $val) {
         $info->{$key} = $val;
     }
     $info->filename = $newName;
     return self::addFile($info);
 }
开发者ID:robinpaulson,项目名称:dataserver,代码行数:22,代码来源:S3.inc.php

示例5: copyObject

 /**
  * copy to s3 on the file on s3
  * @param string $sourceLocationOnS3 - path of source file to be copied in the S3 server
  * @param string $copyLocationOnS3 - path to copy
  * @param string $source_bucket - if the bucket of the source is different from the current S3 bucket
  * @param string $copy_bucket -  if the bucket of to copy is different from the current S3 bucket
  * @param string $permission - the access permissions the file should have, defaults to Public Read Acess
  * @param string $mimeType - set the mime type of the object in S3, defaults to autodetect
  * @return mixed - returns an array with details of the uploaded file on S3 for success, FALSE on failure
  */
 public function copyObject($sourceLocationOnS3, $copyLocationOnS3, $sourceBucket = false, $copyBucket = false, $permission = self::ACL_PUBLIC_READ, $mimeType = array())
 {
     try {
         if ($sourceBucket == false || $sourceBucket == null) {
             $sourceBucket = $this->bucket;
         }
         if ($copyBucket == false || $copyBucket == null) {
             $copyBucket = $this->bucket;
         }
         S3::copyObject($sourceBucket, $sourceLocationOnS3, $copyBucket, $copyLocationOnS3, $permission, array(), $mimeType);
         $info = S3::getObjectInfo($copyBucket, $copyLocationOnS3);
         return array('name' => basename($copyLocationOnS3), 'url' => $this->buildUrlToFile($copyLocationOnS3), 'size' => $info['size']);
     } catch (Exception $e) {
         return false;
     }
 }
开发者ID:dardosordi,项目名称:CakeS3,代码行数:26,代码来源:CakeS3Component.php

示例6: array

    $type = $_POST['type'];
}
if (isset($_POST) && isset($_POST['extension'])) {
    $file_extension = $_POST['extension'];
}
$bucket_name = $aws['bucket'];
$s3 = new S3($aws['key'], $aws['secret']);
$results = array('success' => false, 'url' => 'http://blockstrap.com', 'msg' => 'Unable to copy or delete file');
$year = date('y');
$month = date('m');
$day = date('d');
$original_location = 'temp/' . $year . '/' . $month . '/' . $hash . '.' . $file_extension;
$new_location = 'paid/' . $year . '/' . $month . '/' . $day . '/' . $txid . '.' . $file_extension;
$vars = '?txid=' . $txid . '&extension=' . $file_extension . '&type=' . $type . '&chain=' . $chain;
if ($save === true || $save === 'true') {
    if ($s3->copyObject($bucket_name, $original_location, $bucket_name, $new_location)) {
        if ($s3->deleteObject($bucket_name, $original_location)) {
            $results['success'] = true;
            $results['url'] = $urls['image'] . $vars;
            $results['msg'] = 'Copied and deleted file';
        } else {
            $results['msg'] = 'Unable to delete original file';
        }
    }
} else {
    if ($s3->deleteObject($bucket_name, $original_location)) {
        $results['success'] = true;
        $results['url'] = false;
        $results['msg'] = 'Deleted file';
    } else {
        $results['msg'] = 'Unable to delete file';
开发者ID:habibmasuro,项目名称:hack-pack,代码行数:31,代码来源:upload.php

示例7: uploadProfilePhoto

 function uploadProfilePhoto($name, $path)
 {
     if ($name) {
         $oldname = strtolower($name);
         $ext = substr(strrchr($oldname, "."), 1);
         if ($ext != 'gif' && $ext != 'jpg' && $ext != 'jpeg' && $ext != 'png' && $ext != 'bmp') {
             return "ext";
         } else {
             $targetpath = $path . $name;
             $newname = $name;
             //md5(time().$count).".".$ext;
             if (defined('USE_S3') && USE_S3) {
                 // s3 bucket  start
                 $s3 = new S3(awsAccessKey, awsSecretKey);
                 $s3->putBucket(BUCKET_NAME, S3::ACL_PRIVATE);
                 $folder_orig_Name = 'files/photos/' . trim($newname);
                 //$s3->putObjectFile($targetpath,BUCKET_NAME ,$folder_orig_Name ,S3::ACL_PRIVATE);
                 $s3->copyObject(BUCKET_NAME, DIR_USER_PHOTOS_THUMB . trim($newname), BUCKET_NAME, $folder_orig_Name, S3::ACL_PRIVATE);
                 //s3 bucket end
                 //unlink($targetpath);
             }
             return $newname;
         }
     } else {
         return false;
     }
 }
开发者ID:programster,项目名称:SCRUMptious,代码行数:27,代码来源:FormatComponent.php

示例8: action_update

 public function action_update()
 {
     //template header
     $this->template->title = __('Edit Product');
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Edit Product')));
     $this->template->styles = array('css/sortable.css' => 'screen', '//cdn.jsdelivr.net/bootstrap.datepicker/0.1/css/datepicker.css' => 'screen', '//cdn.jsdelivr.net/jquery.fileupload/9.5.2/css/jquery.fileupload.css' => 'screen', 'css/jasny-bootstrap.min.css' => 'screen');
     $this->template->scripts['footer'] = array('//cdn.jsdelivr.net/bootstrap.datepicker/0.1/js/bootstrap-datepicker.js', 'js/jasny-bootstrap.min.js', 'js/oc-panel/products.js', 'js/jquery-sortable-min.js', '//cdn.jsdelivr.net/jquery.fileupload/9.5.2/js/vendor/jquery.ui.widget.js', '//cdn.jsdelivr.net/jquery.fileupload/9.5.2/js/jquery.iframe-transport.js', '//cdn.jsdelivr.net/jquery.fileupload/9.5.2/js/jquery.fileupload.js');
     $cats = Model_Category::get_as_array();
     $order = Model_Category::get_multidimensional();
     $obj_product = new Model_Product($this->request->param('id'));
     if ($obj_product->loaded()) {
         // get currencies from product, returns array
         $currency = $obj_product::get_currency();
         $this->template->content = View::factory('oc-panel/pages/products/update', array('product' => $obj_product, 'categories' => $cats, 'order_categories' => $order, 'currency' => $currency));
         if ($product = $this->request->post()) {
             // save product file
             if (isset($_FILES['file_name'])) {
                 if ($file = $_FILES['file_name']) {
                     $file = $obj_product->save_product($file);
                     if ($file != FALSE) {
                         $obj_product->file_name = $file;
                     } else {
                         Alert::set(Alert::INFO, __('Product is not uploaded.'));
                     }
                 }
             }
             // deleting single image by path
             $deleted_image = core::post('img_delete');
             if (is_numeric($deleted_image)) {
                 $img_path = $obj_product->gen_img_path($obj_product->id_product, $obj_product->created);
                 $img_seoname = $obj_product->seotitle;
                 // delete image from Amazon S3
                 if (core::config('image.aws_s3_active')) {
                     require_once Kohana::find_file('vendor', 'amazon-s3-php-class/S3', 'php');
                     $s3 = new S3(core::config('image.aws_access_key'), core::config('image.aws_secret_key'));
                     //delete original image
                     $s3->deleteObject(core::config('image.aws_s3_bucket'), $img_path . $img_seoname . '_' . $deleted_image . '.jpg');
                     //delete formated image
                     $s3->deleteObject(core::config('image.aws_s3_bucket'), $img_path . 'thumb_' . $img_seoname . '_' . $deleted_image . '.jpg');
                     //re-ordering image file names
                     for ($i = $deleted_image; $i < $obj_product->has_images; $i++) {
                         //rename original image
                         $s3->copyObject(core::config('image.aws_s3_bucket'), $img_path . $img_seoname . '_' . ($i + 1) . '.jpg', core::config('image.aws_s3_bucket'), $img_path . $img_seoname . '_' . $i . '.jpg', S3::ACL_PUBLIC_READ);
                         $s3->deleteObject(core::config('image.aws_s3_bucket'), $img_path . $img_seoname . '_' . ($i + 1) . '.jpg');
                         //rename formated image
                         $s3->copyObject(core::config('image.aws_s3_bucket'), $img_path . 'thumb_' . $img_seoname . '_' . ($i + 1) . '.jpg', core::config('image.aws_s3_bucket'), $img_path . 'thumb_' . $img_seoname . '_' . $i . '.jpg', S3::ACL_PUBLIC_READ);
                         $s3->deleteObject(core::config('image.aws_s3_bucket'), $img_path . 'thumb_' . $img_seoname . '_' . ($i + 1) . '.jpg');
                     }
                 }
                 if (!is_dir($img_path)) {
                     return FALSE;
                 } else {
                     //delete original image
                     @unlink($img_path . $img_seoname . '_' . $deleted_image . '.jpg');
                     //delete formated image
                     @unlink($img_path . 'thumb_' . $img_seoname . '_' . $deleted_image . '.jpg');
                     //re-ordering image file names
                     for ($i = $deleted_image; $i < $obj_product->has_images; $i++) {
                         rename($img_path . $img_seoname . '_' . ($i + 1) . '.jpg', $img_path . $img_seoname . '_' . $i . '.jpg');
                         rename($img_path . 'thumb_' . $img_seoname . '_' . ($i + 1) . '.jpg', $img_path . 'thumb_' . $img_seoname . '_' . $i . '.jpg');
                     }
                 }
                 $obj_product->has_images = $obj_product->has_images > 0 ? $obj_product->has_images - 1 : 0;
                 $obj_product->updated = Date::unix2mysql();
                 try {
                     $obj_product->save();
                 } catch (Exception $e) {
                     throw HTTP_Exception::factory(500, $e->getMessage());
                 }
                 $this->redirect(Route::url('oc-panel', array('controller' => 'product', 'action' => 'update', 'id' => $obj_product->id_product)));
             }
             // end of img delete
             //delete product file
             $product_delete = core::post('product_delete');
             if ($product_delete) {
                 $p_path = $obj_product->get_file($obj_product->file_name);
                 if (!is_file($p_path)) {
                     return FALSE;
                 } else {
                     @chmod($p_path, 0755);
                     //delete product
                     unlink($p_path);
                     $obj_product->file_name = '';
                     $obj_product->save();
                     $this->redirect(Route::url('oc-panel', array('controller' => 'product', 'action' => 'update', 'id' => $obj_product->id_product)));
                 }
             }
             $product['status'] = (!isset($_POST['status']) or core::post('status') === NULL) ? Model_Product::STATUS_NOACTIVE : Model_Product::STATUS_ACTIVE;
             $product['updated'] = Date::unix2mysql();
             //we do this so we assure use the entire day , nasty
             $product['offer_valid'] .= ' 23:59:59';
             $product['featured'] .= ' 23:59:59';
             // each field in edit product
             foreach ($product as $field => $value) {
                 // do not include submit
                 if ($field != 'submit' and $field != 'notify') {
                     // check if its different, and set it is
                     if ($value != $obj_product->{$field}) {
                         $obj_product->{$field} = $value;
                         // if title is changed, make new seotitle
//.........这里部分代码省略.........
开发者ID:alirezadamash,项目名称:open-eshop,代码行数:101,代码来源:product.php

示例9: copy_file_to_S3

function copy_file_to_S3($origin_file, $destiny_file, $view_proccess = false)
{
    $s3 = new S3(AWS_ACCES_KEY, AWS_SECRET_KEY);
    $success = $s3->copyObject("owlgroup", $origin_file, "owlgroup", $destiny_file, S3::ACL_PUBLIC_READ);
    if ($success) {
        if ($view_proccess) {
            W("{$origin_file} &check; <br>");
            ob_flush();
            flush();
            ob_end_flush();
        }
    } else {
        if ($view_proccess) {
            W("{$origin_file} ERROR <br>");
        }
    }
    return $success;
}
开发者ID:dice9030,项目名称:GestionLogistico,代码行数:18,代码来源:funciones.php

示例10: action_do_edit

 public function action_do_edit($modpack_id)
 {
     if (empty($modpack_id)) {
         return Redirect::to('dashboard');
     }
     $modpack = Modpack::find($modpack_id);
     if (empty($modpack_id)) {
         return Redirect::to('dashboard');
     }
     $rules = array('name' => 'required|unique:modpacks,name,' . $modpack->id, 'slug' => 'required|unique:modpacks,slug,' . $modpack->id);
     $messages = array('name_required' => 'You must enter a modpack name.', 'slug_required' => 'You must enter a modpack slug');
     $validation = Validator::make(Input::all(), $rules, $messages);
     if ($validation->fails()) {
         return Redirect::back()->with_errors($validation->errors);
     }
     $url = Config::get('solder.repo_location') . Input::get('slug') . '/resources/';
     $modpack->name = Input::get('name');
     $oldSlug = $modpack->slug;
     $modpack->slug = Input::get('slug');
     $modpack->icon_md5 = UrlUtils::get_remote_md5($url . 'icon.png');
     $modpack->logo_md5 = UrlUtils::get_remote_md5($url . 'logo_180.png');
     $modpack->background_md5 = UrlUtils::get_remote_md5($url . 'background.jpg');
     $modpack->hidden = Input::get('hidden') ? true : false;
     $modpack->private = Input::get('private') ? true : false;
     $modpack->save();
     $useS3 = Config::get('solder.use_s3');
     if ($useS3) {
         $resourcePath = path('storage') . 'resources/' . $modpack->slug;
     } else {
         $resourcePath = path('public') . 'resources/' . $modpack->slug;
     }
     /* Create new resources directory for modpack */
     if (!file_exists($resourcePath)) {
         mkdir($resourcePath);
     }
     /* If slug changed, move resources and delete old slug directory */
     if ($oldSlug != $modpack->slug) {
         $oldPath = path('public') . 'resources/' . $oldSlug;
         if (Config::get('solder.use_s3')) {
             try {
                 S3::copyObject(Config::get('solder.bucket'), 'resources/' . $oldSlug . '/logo.png', Config::get('solder.bucket'), 'resources/' . $modpack->slug . '/logo.png', S3::ACL_PUBLIC_READ);
                 S3::copyObject(Config::get('solder.bucket'), 'resources/' . $oldSlug . '/background.png', Config::get('solder.bucket'), 'resources/' . $modpack->slug . '/background.png', S3::ACL_PUBLIC_READ);
                 S3::copyObject(Config::get('solder.bucket'), 'resources/' . $oldSlug . '/icon.png', Config::get('solder.bucket'), 'resources/' . $modpack->slug . '/icon.png', S3::ACL_PUBLIC_READ);
                 S3::deleteObject(Config::get('solder.bucket'), 'resources/' . $oldSlug . '/logo.png');
                 S3::deleteObject(Config::get('solder.bucket'), 'resources/' . $oldSlug . '/background.png');
                 S3::deleteObject(Config::get('solder.bucket'), 'resources/' . $oldSlug . '/icon.png');
             } catch (Exception $e) {
             }
             $oldPath = path('storage') . 'resources/' . $oldSlug;
         }
         if (file_exists($oldPath . "/logo.png")) {
             copy($oldPath . "/logo.png", $resourcePath . "/logo.png");
             unlink($oldPath . "/logo.png");
         }
         if (file_exists($oldPath . "/background.png")) {
             copy($oldPath . "/background.png", $resourcePath . "/background.png");
             unlink($oldPath . "/background.png");
         }
         if (file_exists($oldPath . "/icon.png")) {
             copy($oldPath . "/icon.png", $resourcePath . "/icon.png");
             unlink($oldPath . "/icon.png");
         }
         rmdir($oldPath);
     }
     /* Image dohickery */
     $logo = Input::file('logo');
     if (!empty($logo['name'])) {
         $success = Resizer::open(Input::file('logo'))->resize(180, 110, 'exact')->save($resourcePath . "/logo.png", 90);
         if ($useS3) {
             S3::putObject(S3::inputFile($resourcePath . '/logo.png', false), Config::get('solder.bucket'), 'resources/' . $modpack->slug . '/logo.png', S3::ACL_PUBLIC_READ);
         }
         if ($success) {
             $modpack->logo = true;
             $modpack->logo_md5 = md5_file($resourcePath . "/logo.png");
         }
     }
     $background = Input::file('background');
     if (!empty($background['name'])) {
         $success = Resizer::open(Input::file('background'))->resize(880, 520, 'exact')->save($resourcePath . "/background.png", 90);
         if ($useS3) {
             S3::putObject(S3::inputFile($resourcePath . '/background.png', false), Config::get('solder.bucket'), 'resources/' . $modpack->slug . '/background.png', S3::ACL_PUBLIC_READ);
         }
         if ($success) {
             $modpack->background = true;
             $modpack->background_md5 = md5_file($resourcePath . "/background.png");
         }
     }
     $icon = Input::file('icon');
     if (!empty($icon['name'])) {
         $success = Resizer::open(Input::file('icon'))->resize(50, 50, 'exact')->save($resourcePath . "/icon.png", 90);
         if ($useS3) {
             S3::putObject(S3::inputFile($resourcePath . '/icon.png', false), Config::get('solder.bucket'), 'resources/' . $modpack->slug . '/icon.png', S3::ACL_PUBLIC_READ);
         }
         if ($success) {
             $modpack->icon = true;
             $modpack->icon_md5 = md5_file($resourcePath . "/icon.png");
         }
     }
     $modpack->save();
     Cache::forget('modpack.' . $modpack->slug);
//.........这里部分代码省略.........
开发者ID:kreezxil,项目名称:TechnicSolder,代码行数:101,代码来源:modpack.php

示例11: set_primary_image

 /**
  * Set primary image by swapping ids
  * @param  integer $primary_image 
  * @return void                
  */
 public function set_primary_image($primary_image)
 {
     // if ad doesn't have at least two images do nothing
     if ($this->has_images < 2) {
         return;
     }
     $img_path = $this->image_path();
     // delete image from Amazon S3
     if (core::config('image.aws_s3_active')) {
         require_once Kohana::find_file('vendor', 'amazon-s3-php-class/S3', 'php');
         $s3 = new S3(core::config('image.aws_access_key'), core::config('image.aws_secret_key'));
         //re-ordering image file names
         $s3->copyObject(core::config('image.aws_s3_bucket'), $this->image_name('1'), core::config('image.aws_s3_bucket'), $this->image_name('1_old'), S3::ACL_PUBLIC_READ);
         $s3->deleteObject(core::config('image.aws_s3_bucket'), $this->image_name('1'));
         $s3->copyObject(core::config('image.aws_s3_bucket'), $this->image_name('1', 'thumb'), core::config('image.aws_s3_bucket'), $this->image_name('1_old', 'thumb'), S3::ACL_PUBLIC_READ);
         $s3->deleteObject(core::config('image.aws_s3_bucket'), $this->image_name('1', 'thumb'));
         $s3->copyObject(core::config('image.aws_s3_bucket'), $this->image_name($primary_image), core::config('image.aws_s3_bucket'), $this->image_name('1'), S3::ACL_PUBLIC_READ);
         $s3->deleteObject(core::config('image.aws_s3_bucket'), $this->image_name($primary_image));
         $s3->copyObject(core::config('image.aws_s3_bucket'), $this->image_name($primary_image, 'thumb'), core::config('image.aws_s3_bucket'), $this->image_name('1', 'thumb'), S3::ACL_PUBLIC_READ);
         $s3->deleteObject(core::config('image.aws_s3_bucket'), $this->image_name($primary_image, 'thumb'));
         $s3->copyObject(core::config('image.aws_s3_bucket'), $this->image_name('1_old'), core::config('image.aws_s3_bucket'), $this->image_name($primary_image), S3::ACL_PUBLIC_READ);
         $s3->deleteObject(core::config('image.aws_s3_bucket'), $this->image_name('1_old'));
         $s3->copyObject(core::config('image.aws_s3_bucket'), $this->image_name('1_old', 'thumb'), core::config('image.aws_s3_bucket'), $this->image_name($primary_image, 'thumb'), S3::ACL_PUBLIC_READ);
         $s3->deleteObject(core::config('image.aws_s3_bucket'), $this->image_name('1_old', 'thumb'));
     }
     //re-ordering image file names
     @rename($this->image_name('1'), $this->image_name('1_old'));
     @rename($this->image_name('1', 'thumb'), $this->image_name('1_old', 'thumb'));
     @rename($this->image_name($primary_image), $this->image_name('1'));
     @rename($this->image_name($primary_image, 'thumb'), $this->image_name('1', 'thumb'));
     @rename($this->image_name('1_old'), $this->image_name($primary_image));
     @rename($this->image_name('1_old', 'thumb'), $this->image_name($primary_image, 'thumb'));
     $this->last_modified = Date::unix2mysql();
     try {
         $this->save();
         return TRUE;
     } catch (Exception $e) {
         throw HTTP_Exception::factory(500, $e->getMessage());
     }
     return FALSE;
 }
开发者ID:kleitz,项目名称:openclassifieds2,代码行数:46,代码来源:ad.php

示例12: _createS3File

 private function _createS3File()
 {
     //format the name and stuff
     $filename = basename($this->args('key'));
     $filename = str_replace(" ", "_", $filename);
     $filename = preg_replace("/[^-_.+[0-9a-zA-Z]/", "", $filename);
     $path = "assets/" . S3File::getNiceDir($filename);
     //check our info out.
     $info = $this->_lookupFileInfo();
     //create new s3 file
     $file = new S3File();
     $file->set('user_id', User::$me->id);
     $file->set('type', $info['type']);
     $file->set('size', $info['size']);
     $file->set('hash', $info['hash']);
     $file->set('add_date', date('Y-m-d H:i:s'));
     $file->set('bucket', AMAZON_S3_BUCKET_NAME);
     $file->set('path', $path);
     $file->save();
     //copy to new location in s3.
     $s3 = new S3(AMAZON_AWS_KEY, AMAZON_AWS_SECRET);
     $s3->copyObject($this->args('bucket'), $this->args('key'), AMAZON_S3_BUCKET_NAME, $path, S3::ACL_PUBLIC_READ);
     //remove the uploaded file.
     $s3->deleteObject($this->args('bucket'), $this->args('key'));
     return $file;
 }
开发者ID:ricberw,项目名称:BotQueue,代码行数:26,代码来源:upload.php

示例13: move_item

 static function move_item($old_item, $new_item)
 {
     self::get_s3();
     S3::copyObject(module::get_var("aws_s3", "bucket_name"), self::get_resource_url("fs/" . $old_item->relative_path()), module::get_var("aws_s3", "bucket_name"), self::get_resource_url("fs/" . $new_item->relative_path()), $new_item->view_1 ? S3::ACL_PUBLIC_READ : S3::ACL_PRIVATE);
     S3::deleteObject(module::get_var("aws_s3", "bucket_name"), self::get_resource_url("fs/" . $old_item->relative_path()));
     S3::copyObject(module::get_var("aws_s3", "bucket_name"), self::get_resource_url("rs/" . $old_item->relative_path()), module::get_var("aws_s3", "bucket_name"), self::get_resource_url("rs/" . $new_item->relative_path()), $new_item->view_1 ? S3::ACL_PUBLIC_READ : S3::ACL_PRIVATE);
     S3::deleteObject(module::get_var("aws_s3", "bucket_name"), self::get_resource_url("rs/" . $old_item->relative_path()));
     S3::copyObject(module::get_var("aws_s3", "bucket_name"), self::get_resource_url("th/" . $old_item->relative_path()), module::get_var("aws_s3", "bucket_name"), self::get_resource_url("th/" . $new_item->relative_path()), $new_item->view_1 ? S3::ACL_PUBLIC_READ : S3::ACL_PRIVATE);
     S3::deleteObject(module::get_var("aws_s3", "bucket_name"), self::get_resource_url("th/" . $old_item->relative_path()));
 }
开发者ID:Retroguy,项目名称:gallery3-contrib,代码行数:10,代码来源:aws_s3.php

示例14: copyObject

 public function copyObject($srcBucket, $srcUri, $bucket, $uri)
 {
     return S3::copyObject($srcBucket, $srcUri, $bucket, $uri);
 }
开发者ID:pneff,项目名称:binarypool,代码行数:4,代码来源:Wrapper.php

示例15: array

 $s3 = new S3($GLOBALS['AWSkey'], $GLOBALS['AWSsecret']);
 $doneagroups = array();
 while ($row = mysql_fetch_row($result)) {
     //set path to aid/asid/  or aid/agroupid/  - won't interefere with random values, and easier to do.
     if ($row[1] == 0) {
         $path = $row[5] . '/' . $row[0];
         $curs3asid = $row[0];
     } else {
         $path = $row[5] . '/' . $row[1];
         $curs3asid = $row[1];
     }
     if ($row[1] == 0 || !in_array($row[1], $doneagroups)) {
         preg_match_all('/@FILE:(.*?)@/', $row[2] . $row[3] . $row[4], $matches);
         $tomove = array_unique($matches[1]);
         foreach ($tomove as $file) {
             if (@$s3->copyObject($GLOBALS['AWSbucket'], "adata/{$curs3asid}/{$file}", $GLOBALS['AWSbucket'], "adata/{$path}/{$file}")) {
                 @$s3->deleteObject($GLOBALS['AWSbucket'], "adata/{$curs3asid}/{$file}");
             }
         }
         if ($row[1] > 0) {
             $doneagroups[] = $row[1];
         }
     }
     $la = addslashes(preg_replace('/@FILE:/', "@FILE:{$path}/", $row[2]));
     $bla = addslashes(preg_replace('/@FILE:/', "@FILE:{$path}/", $row[3]));
     $rla = addslashes(preg_replace('/@FILE:/', "@FILE:{$path}/", $row[4]));
     $query = "UPDATE imas_assessment_sessions SET lastanswers='{$la}',bestlastanswers='{$bla}',reviewlastanswers='{$rla}' WHERE id={$row[0]}";
     $res = mysql_query($query) or die("Query failed : {$query}:" . mysql_error());
 }
 echo 'Done up through s3 file change.  <a href="upgrade.php?last=30.5">Continue</a>';
 exit;
开发者ID:ericvanboven,项目名称:IMathAS,代码行数:31,代码来源:upgrade.php


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