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


PHP AmazonS3::get_object方法代码示例

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


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

示例1: file_download

 /**
  * @param $jobid
  * @param $get_file
  */
 public function file_download($jobid, $get_file)
 {
     try {
         $s3 = new AmazonS3(array('key' => BackWPup_Option::get($jobid, 's3accesskey'), 'secret' => BackWPup_Encryption::decrypt(BackWPup_Option::get($jobid, 's3secretkey')), 'certificate_authority' => TRUE));
         $base_url = $this->get_s3_base_url(BackWPup_Option::get($jobid, 's3region'), BackWPup_Option::get($jobid, 's3base_url'));
         if (stristr($base_url, 'amazonaws.com')) {
             $s3->set_region(str_replace(array('http://', 'https://'), '', $base_url));
         } else {
             $s3->set_hostname(str_replace(array('http://', 'https://'), '', $base_url));
             $s3->allow_hostname_override(FALSE);
             if (substr($base_url, -1) == '/') {
                 $s3->enable_path_style(TRUE);
             }
         }
         if (stristr($base_url, 'http://')) {
             $s3->disable_ssl();
         }
         $s3file = $s3->get_object(BackWPup_Option::get($jobid, 's3bucket'), $get_file);
     } catch (Exception $e) {
         die($e->getMessage());
     }
     if ($s3file->status == 200) {
         header("Pragma: public");
         header("Expires: 0");
         header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
         header("Content-Type: application/octet-stream");
         header("Content-Disposition: attachment; filename=" . basename($get_file) . ";");
         header("Content-Transfer-Encoding: binary");
         header("Content-Length: " . $s3file->header->_info->size_download);
         @set_time_limit(0);
         echo $s3file->body;
         die;
     }
 }
开发者ID:agileontheweb,项目名称:xvp,代码行数:38,代码来源:class-destination-s3-v1.php

示例2: basename

 function process_remote_copy($destination_type, $file, $settings)
 {
     pb_backupbuddy::status('details', 'Copying remote `' . $destination_type . '` file `' . $file . '` down to local.');
     pb_backupbuddy::set_greedy_script_limits();
     if (!class_exists('backupbuddy_core')) {
         require_once pb_backupbuddy::plugin_path() . '/classes/core.php';
     }
     // Determine destination filename.
     $destination_file = backupbuddy_core::getBackupDirectory() . basename($file);
     if (file_exists($destination_file)) {
         $destination_file = str_replace('backup-', 'backup_copy_' . pb_backupbuddy::random_string(5) . '-', $destination_file);
     }
     pb_backupbuddy::status('details', 'Filename of resulting local copy: `' . $destination_file . '`.');
     if ($destination_type == 'stash2') {
         require_once ABSPATH . 'wp-admin/includes/file.php';
         pb_backupbuddy::status('details', 'About to begin downloading from URL.');
         $download = download_url($url);
         pb_backupbuddy::status('details', 'Download process complete.');
         if (is_wp_error($download)) {
             $error = 'Error #832989323: Unable to download file `' . $file . '` from URL: `' . $url . '`. Details: `' . $download->get_error_message() . '`.';
             pb_backupbuddy::status('error', $error);
             pb_backupbuddy::alert($error);
             return false;
         } else {
             if (false === copy($download, $destination_file)) {
                 $error = 'Error #3329383: Unable to copy file from `' . $download . '` to `' . $destination_file . '`.';
                 pb_backupbuddy::status('error', $error);
                 pb_backupbuddy::alert($error);
                 @unlink($download);
                 return false;
             } else {
                 pb_backupbuddy::status('details', 'File saved to `' . $destination_file . '`.');
                 @unlink($download);
                 return true;
             }
         }
     }
     // end stash2.
     if ($destination_type == 'stash') {
         $itxapi_username = $settings['itxapi_username'];
         $itxapi_password = $settings['itxapi_password'];
         // Load required files.
         pb_backupbuddy::status('details', 'Load Stash files.');
         require_once pb_backupbuddy::plugin_path() . '/destinations/stash/init.php';
         require_once dirname(dirname(__FILE__)) . '/destinations/_s3lib/aws-sdk/sdk.class.php';
         require_once pb_backupbuddy::plugin_path() . '/destinations/stash/lib/class.itx_helper.php';
         // Talk with the Stash API to get access to do things.
         pb_backupbuddy::status('details', 'Authenticating Stash for remote copy to local.');
         $stash = new ITXAPI_Helper(pb_backupbuddy_destination_stash::ITXAPI_KEY, pb_backupbuddy_destination_stash::ITXAPI_URL, $itxapi_username, $itxapi_password);
         $manage_url = $stash->get_manage_url();
         $request = new RequestCore($manage_url);
         $response = $request->send_request(true);
         // Validate response.
         if (!$response->isOK()) {
             $error = 'Request for management credentials failed.';
             pb_backupbuddy::status('error', $error);
             pb_backupbuddy::alert($error);
             return false;
         }
         if (!($manage_data = json_decode($response->body, true))) {
             $error = 'Did not get valid JSON response.';
             pb_backupbuddy::status('error', $error);
             pb_backupbuddy::alert($error);
             return false;
         }
         if (isset($manage_data['error'])) {
             $error = 'Error: ' . implode(' - ', $manage_data['error']);
             pb_backupbuddy::status('error', $error);
             pb_backupbuddy::alert($error);
             return false;
         }
         // Connect to S3.
         pb_backupbuddy::status('details', 'Instantiating S3 object.');
         $s3 = new AmazonS3($manage_data['credentials']);
         pb_backupbuddy::status('details', 'About to get Stash object `' . $file . '`...');
         try {
             $response = $s3->get_object($manage_data['bucket'], $manage_data['subkey'] . pb_backupbuddy_destination_stash::get_remote_path() . $file, array('fileDownload' => $destination_file));
         } catch (Exception $e) {
             pb_backupbuddy::status('error', 'Error #5443984: ' . $e->getMessage());
             error_log('err:' . $e->getMessage());
             return false;
         }
         if ($response->isOK()) {
             pb_backupbuddy::status('details', 'Stash copy to local success.');
             return true;
         } else {
             pb_backupbuddy::status('error', 'Error #894597845. Stash copy to local FAILURE. Details: `' . print_r($response, true) . '`.');
             return false;
         }
     } elseif ($destination_type == 'gdrive') {
         die('Not implemented here.');
         require_once pb_backupbuddy::plugin_path() . '/destinations/gdrive/init.php';
         $settings = array_merge(pb_backupbuddy_destination_gdrive::$default_settings, $settings);
         if (true === pb_backupbuddy_destination_gdrive::getFile($settings, $file, $destination_file)) {
             // success
             pb_backupbuddy::status('details', 'Google Drive copy to local success.');
             return true;
         } else {
             // fail
             pb_backupbuddy::status('details', 'Error #2332903. Google Drive copy to local FAILURE.');
//.........这里部分代码省略.........
开发者ID:elephantcode,项目名称:elephantcode,代码行数:101,代码来源:cron.php

示例3: array

    echo '<br>';
}
// Handle copying files to local
if (pb_backupbuddy::_GET('cpy_file') != '') {
    pb_backupbuddy::alert('The remote file is now being copied to your local backups. If the backup gets marked as bad during copying, please wait a bit then click the `Refresh` icon to rescan after the transfer is complete.');
    echo '<br>';
    pb_backupbuddy::status('details', 'Scheduling Cron for creating Stash copy.');
    backupbuddy_core::schedule_single_event(time(), 'process_remote_copy', array('stash', pb_backupbuddy::_GET('cpy_file'), $settings));
    spawn_cron(time() + 150);
    // Adds > 60 seconds to get around once per minute cron running limit.
    update_option('_transient_doing_cron', 0);
    // Prevent cron-blocking for next item.
}
// Handle download link
if (pb_backupbuddy::_GET('downloadlink_file') != '') {
    $link = $s3->get_object($manage_data['bucket'], $manage_data['subkey'] . $remote_path . pb_backupbuddy::_GET('downloadlink_file'), array('preauth' => time() + 3600));
    pb_backupbuddy::alert('You may download this backup (' . pb_backupbuddy::_GET('downloadlink_file') . ') with <a href="' . $link . '">this link</a>. The link is valid for one hour.');
    echo '<br>';
}
// QUOTA INFORMATION.
$account_info = pb_backupbuddy_destination_stash::get_quota(array('itxapi_username' => $itxapi_username, 'itxapi_password' => $itxapi_password), false);
/*
echo '<pre>';
print_r( $account_info );
echo '</pre>';
*/
echo pb_backupbuddy_destination_stash::get_quota_bar($account_info);
echo '<div style="text-align: center;">';
echo '
<b>Upgrade to get more Stash space:</b> &nbsp;
<a href="https://ithemes.com/member/cart.php?action=add&id=290" target="_blank" style="text-decoration: none; font-weight: 300;">+ 5GB</a>, &nbsp;
开发者ID:AgilData,项目名称:WordPress-Skeleton,代码行数:31,代码来源:_manage.php

示例4: count

 print "Processing message with " . count($imageKeys) . " images:\n";
 // Create destination image
 $outX = BORDER_LEFT + BORDER_RIGHT + IMAGES_ACROSS * THUMB_SIZE + (IMAGES_ACROSS - 1) * GAP_SIZE;
 $outY = BORDER_TOP + BORDER_BOTTOM + IMAGES_DOWN * THUMB_SIZE + (IMAGES_DOWN - 1) * GAP_SIZE;
 $imageOut = ImageCreateTrueColor($outX, $outY);
 // Paint the image white
 ImageFill($imageOut, 0, 0, ImageColorAllocate($imageOut, 255, 255, 255));
 // Draw a border in destination image
 ImageRectangle($imageOut, 0, 0, $outX - 1, $outY - 1, ImageColorAllocate($imageOut, 0, 0, 0));
 // Do the work
 $nextX = BORDER_LEFT;
 $nextY = BORDER_TOP;
 foreach ($imageKeys as $imageKey) {
     // Fetch the image
     print "  Fetch image '{$imageKey}'\n";
     $image = $s3->get_object(BOOK_BUCKET, $imageKey);
     // Convert it to GD format
     $imageBits = ImageCreateFromString($image->body);
     // Copy it to proper spot in the destination
     print "  Render image at {$nextX}, {$nextY}\n";
     ImageCopy($imageOut, $imageBits, $nextX, $nextY, 0, 0, ImageSx($imageBits), ImageSy($imageBits));
     // Draw a border around it
     ImageRectangle($imageOut, $nextX, $nextY, $nextX + ImageSx($imageBits), $nextY + ImageSy($imageBits), ImageColorAllocate($imageOut, 0, 0, 0));
     // Update position for next image
     $nextX += THUMB_SIZE + GAP_SIZE;
     if ($nextX + THUMB_SIZE > $outX) {
         $nextX = BORDER_LEFT;
         $nextY += THUMB_SIZE + GAP_SIZE;
     }
 }
 // Get the bits of the destination image
开发者ID:websider,项目名称:amazon-web-services,代码行数:31,代码来源:render_images.php

示例5: basename

 function process_remote_copy($destination_type, $file, $settings)
 {
     pb_backupbuddy::status('details', 'Copying remote `' . $destination_type . '` file `' . $file . '` down to local.');
     pb_backupbuddy::set_greedy_script_limits();
     if (!class_exists('backupbuddy_core')) {
         require_once pb_backupbuddy::plugin_path() . '/classes/core.php';
     }
     // Determine destination filename.
     $destination_file = backupbuddy_core::getBackupDirectory() . basename($file);
     if (file_exists($destination_file)) {
         $destination_file = str_replace('backup-', 'backup_copy_' . pb_backupbuddy::random_string(5) . '-', $destination_file);
     }
     pb_backupbuddy::status('details', 'Filename of resulting local copy: `' . $destination_file . '`.');
     if ($destination_type == 'stash') {
         $itxapi_username = $settings['itxapi_username'];
         $itxapi_password = $settings['itxapi_password'];
         // Load required files.
         require_once pb_backupbuddy::plugin_path() . '/destinations/stash/init.php';
         require_once pb_backupbuddy::plugin_path() . '/destinations/stash/lib/class.itx_helper.php';
         // Talk with the Stash API to get access to do things.
         $stash = new ITXAPI_Helper(pb_backupbuddy_destination_stash::ITXAPI_KEY, pb_backupbuddy_destination_stash::ITXAPI_URL, $itxapi_username, $itxapi_password);
         $manage_url = $stash->get_manage_url();
         $request = new RequestCore($manage_url);
         $response = $request->send_request(true);
         // Validate response.
         if (!$response->isOK()) {
             $error = 'Request for management credentials failed.';
             pb_backupbuddy::status('error', $error);
             pb_backupbuddy::alert($error);
             return false;
         }
         if (!($manage_data = json_decode($response->body, true))) {
             $error = 'Did not get valid JSON response.';
             pb_backupbuddy::status('error', $error);
             pb_backupbuddy::alert($error);
             return false;
         }
         if (isset($manage_data['error'])) {
             $error = 'Error: ' . implode(' - ', $manage_data['error']);
             pb_backupbuddy::status('error', $error);
             pb_backupbuddy::alert($error);
             return false;
         }
         // Connect to Amazon S3.
         pb_backupbuddy::status('details', 'Instantiating S3 object.');
         $s3 = new AmazonS3($manage_data['credentials']);
         pb_backupbuddy::status('details', 'About to get Stash object `' . $file . '`...');
         $response = $s3->get_object($manage_data['bucket'], $manage_data['subkey'] . '/' . $file, array('fileDownload' => $destination_file));
         if ($response->isOK()) {
             pb_backupbuddy::status('details', 'Stash copy to local success.');
             return true;
         } else {
             pb_backupbuddy::status('error', 'Error #894597845. Stash copy to local FAILURE. Details: `' . print_r($response, true) . '`.');
             return false;
         }
     } elseif ($destination_type == 's3') {
         require_once pb_backupbuddy::plugin_path() . '/destinations/s3/init.php';
         if (true === pb_backupbuddy_destination_s3::download_file($settings, $file, $destination_file)) {
             // success
             pb_backupbuddy::status('details', 'S3 copy to local success.');
             return true;
         } else {
             // fail
             pb_backupbuddy::status('details', 'Error #85448774. S3 copy to local FAILURE.');
             return false;
         }
     } else {
         pb_backupbuddy::status('error', 'Error #859485. Unknown destination type for remote copy `' . $destination_type . '`.');
         return false;
     }
 }
开发者ID:netfor,项目名称:nextrading,代码行数:71,代码来源:cron.php

示例6: extract

 function get_amazons3_backup_bwd_comp($args)
 {
     if ($this->iwp_mmb_function_exists('curl_init')) {
         require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/amazon_s3_bwd_comp/sdk.class.php';
         extract($args);
         $temp = '';
         try {
             CFCredentials::set(array('development' => array('key' => trim($as3_access_key), 'secret' => trim(str_replace(' ', '+', $as3_secure_key)), 'default_cache_config' => '', 'certificate_authority' => true), '@default' => 'development'));
             $s3 = new AmazonS3();
             if ($as3_site_folder == true) {
                 if (!empty($as3_directory)) {
                     $as3_directory .= '/' . $this->site_name;
                 } else {
                     $as3_directory = $this->site_name;
                 }
             }
             if (empty($as3_directory)) {
                 $single_as3_file = $backup_file;
             } else {
                 $single_as3_file = $as3_directory . '/' . $backup_file;
             }
             //$temp = ABSPATH . 'iwp_temp_backup.zip';
             $temp = wp_tempnam('iwp_temp_backup.zip');
             $s3->get_object($as3_bucket, $single_as3_file, array("fileDownload" => $temp));
         } catch (Exception $e) {
             return false;
         }
         return $temp;
     } else {
         return array('error' => 1);
     }
 }
开发者ID:Trideon,项目名称:gigolo,代码行数:32,代码来源:backup.class.multicall.php

示例7: header

         header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found");
         header("Status: 404 Not Found");
         die;
     }
     break;
 case 'downloads3':
     //Download S3 Backup
     check_admin_referer('download-backup');
     if (!class_exists('AmazonS3')) {
         require_once realpath(dirname(__FILE__) . '/../libs/aws/sdk.class.php');
     }
     $jobs = get_option('backwpup_jobs');
     $jobid = $_GET['jobid'];
     try {
         $s3 = new AmazonS3(array('key' => $jobs[$jobid]['awsAccessKey'], 'secret' => $jobs[$jobid]['awsSecretKey'], 'certificate_authority' => true));
         $s3file = $s3->get_object($jobs[$jobid]['awsBucket'], $_GET['file']);
     } catch (Exception $e) {
         die($e->getMessage());
     }
     if ($s3file->status == 200) {
         header("Pragma: public");
         header("Expires: 0");
         header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
         header("Content-Type: " . $s3file->header->_info->content_type);
         header("Content-Type: application/force-download");
         header("Content-Type: application/octet-stream");
         header("Content-Type: application/download");
         header("Content-Disposition: attachment; filename=" . basename($_GET['file']) . ";");
         header("Content-Transfer-Encoding: binary");
         header("Content-Length: " . $s3file->header->_info->size_download);
         echo $s3file->body;
开发者ID:hscale,项目名称:webento,代码行数:31,代码来源:header_backwpupbackups.php

示例8: count

 print "Processing message with " . count($imageKeys) . " images:\n";
 // Create destination image
 $outX = BORDER_LEFT + BORDER_RIGHT + IMAGES_ACROSS * THUMB_SIZE + (IMAGES_ACROSS - 1) * GAP_SIZE;
 $outY = BORDER_TOP + BORDER_BOTTOM + IMAGES_DOWN * THUMB_SIZE + (IMAGES_DOWN - 1) * GAP_SIZE;
 $imageOut = ImageCreateTrueColor($outX, $outY);
 // Paint the image white
 ImageFill($imageOut, 0, 0, ImageColorAllocate($imageOut, 255, 255, 255));
 // Draw a border in destination image
 ImageRectangle($imageOut, 0, 0, $outX - 1, $outY - 1, ImageColorAllocate($imageOut, 0, 0, 0));
 // Do the work
 $nextX = BORDER_LEFT;
 $nextY = BORDER_TOP;
 foreach ($imageKeys as $imageKey) {
     // Fetch the image
     print "  Fetch image '{$imageKey}'\n";
     $image = $s3->get_object($bucket, $imageKey);
     // Convert it to GD format
     $imageBits = ImageCreateFromString($image->body);
     // Copy it to proper spot in the destination
     print "  Render image at {$nextX}, {$nextY}\n";
     ImageCopy($imageOut, $imageBits, $nextX, $nextY, 0, 0, ImageSx($imageBits), ImageSy($imageBits));
     // Draw a border around it
     ImageRectangle($imageOut, $nextX, $nextY, $nextX + ImageSx($imageBits), $nextY + ImageSy($imageBits), ImageColorAllocate($imageOut, 0, 0, 0));
     // Update position for next image
     $nextX += THUMB_SIZE + GAP_SIZE;
     if ($nextX + THUMB_SIZE > $outX) {
         $nextX = BORDER_LEFT;
         $nextY += THUMB_SIZE + GAP_SIZE;
     }
 }
 // Get the bits of the destination image
开发者ID:jsh,项目名称:BarrBookCode,代码行数:31,代码来源:render_images.php

示例9: moveEpisodeFileFromAmazon

 public function moveEpisodeFileFromAmazon()
 {
     ProjectConfiguration::registerAws();
     $file_location = ProjectConfiguration::getEpisodeAudioFileLocalDirectory();
     $s3 = new AmazonS3();
     $bucket = $this->getSubreddit()->getBucketName();
     if (!$s3->if_bucket_exists($bucket)) {
         throw new Exception("Amazon bucket '{$bucket}' does not exist!");
     }
     $response = $s3->get_object($bucket, $this->getNiceFilename(), array('fileDownload' => $file_location . $this->getAudioFile()));
     if (!$response->isOK()) {
         throw new Exception('There was an error retrieving from Amazon.');
     }
     $this->deleteEpisodeFileFromAmazon();
     $this->setFileIsRemote(false);
 }
开发者ID:nocoolnametom,项目名称:OpenMicNight,代码行数:16,代码来源:Episode.class.php

示例10: realpath

    $progress_bar = $GLOBALS['progress_bar'];
    // Have we updated the format with updated information yet?
    if (!$progress_bar->UPDATED) {
        // Add the Content-Length of the file as the max number of bytes.
        $progress_bar->reset('* %fraction% KB [%bar%] %percent%', '=>', ' ', 100, curl_getinfo($curl_handle, CURLINFO_CONTENT_LENGTH_DOWNLOAD));
        $progress_bar->UPDATED = true;
    }
    // Update the progress bar with the cumulative number of bytes downloaded.
    $progress_bar->update(curl_getinfo($curl_handle, CURLINFO_SIZE_DOWNLOAD));
}
// Add some spacing above the progress bar.
echo PHP_EOL;
echo 'Downloading http://aws-sdk-for-php.s3.amazonaws.com/demo/big-buck-bunny.mp4' . PHP_EOL;
echo 'Writing to ' . realpath('./downloads') . '/big-buck-bunny.mp4' . PHP_EOL;
// Download a public object.
$response = $s3->get_object('aws-sdk-for-php', 'demo/big-buck-bunny.mp4', array('fileDownload' => './downloads/big-buck-bunny.mp4'));
// Add some spacing below the progress bar.
echo PHP_EOL;
/*%******************************************************************************************%*/
// UPLOAD SAMPLE FILE TO S3
$_100_percent = 0;
// Create a bucket to upload to
$bucket = 's3-progress-bar-' . strtolower($s3->key);
if (!$s3->if_bucket_exists($bucket)) {
    $response = $s3->create_bucket($bucket, AmazonS3::REGION_US_E1);
    if (!$response->isOK()) {
        die('Could not create `' . $bucket . '`.');
    }
}
// Instantiate a new progress bar.
// We won't know the max number of bytes until the download starts, so we'll handle that in our callback.
开发者ID:anil-kodali,项目名称:aws-sdk-for-php,代码行数:31,代码来源:cli-s3_progress_bar.php


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