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


PHP S3::getObject方法代码示例

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


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

示例1: getLocalCopy

 /**
  * @inheritDoc BaseAssetSourceType::getLocalCopy()
  *
  * @param AssetFileModel $file
  *
  * @return mixed
  */
 public function getLocalCopy(AssetFileModel $file)
 {
     $location = AssetsHelper::getTempFilePath($file->getExtension());
     $this->_prepareForRequests();
     $this->_s3->getObject($this->getSettings()->bucket, $this->_getS3Path($file), $location);
     return $location;
 }
开发者ID:webremote,项目名称:craft_boilerplate,代码行数:14,代码来源:S3AssetSourceType.php

示例2:

 function process_s3_copy($s3file, $accesskey, $secretkey, $bucket, $directory)
 {
     pb_backupbuddy::set_greedy_script_limits();
     require_once pb_backupbuddy::plugin_path() . '/lib/s3/s3.php';
     $s3 = new S3($accesskey, $secretkey);
     $destination_file = ABSPATH . 'wp-content/uploads/backupbuddy_backups/' . $s3file;
     if (file_exists($destination_file)) {
         $destination_file = str_replace('backup-', 'backup_copy_' . pb_backupbuddy::random_string(5) . '-', $destination_file);
     }
     $s3->getObject($bucket, $directory . $s3file, $destination_file);
 }
开发者ID:sonnetmedia,项目名称:otherpress.com,代码行数:11,代码来源:cron.php

示例3: get

 public static function get($file, $type, $output = false)
 {
     global $globals;
     $uri = "{$type}/{$file}";
     S3::setAuth($globals['Amazon_access_key'], $globals['Amazon_secret_key']);
     if ($object = @S3::getObject($globals['Amazon_S3_media_bucket'], $uri, $output)) {
         return $object;
     }
     syslog(LOG_NOTICE, "Meneame, failed to get {$uri} from S3");
     @unlink($output);
     return false;
 }
开发者ID:brainsqueezer,项目名称:fffff,代码行数:12,代码来源:media.php

示例4: downloadFile

 public static function downloadFile(array $localFileItemInfo, $savePath, $filename = false)
 {
     Zotero_S3::requireLibrary();
     S3::setAuth(Z_CONFIG::$S3_ACCESS_KEY, Z_CONFIG::$S3_SECRET_KEY);
     if (!file_exists($savePath)) {
         throw new Exception("Path '{$savePath}' does not exist");
     }
     if (!is_dir($savePath)) {
         throw new Exception("'{$savePath}' is not a directory");
     }
     $response = S3::getObject(Z_CONFIG::$S3_BUCKET, self::getPathPrefix($localFileItemInfo['hash'], $localFileItemInfo['zip']) . $localFileItemInfo['filename'], $savePath . "/" . ($filename ? $filename : $localFileItemInfo['filename']));
     return $response;
 }
开发者ID:robinpaulson,项目名称:dataserver,代码行数:13,代码来源:S3.inc.php

示例5: get

 public static function get($file, $type, $output = false)
 {
     global $globals;
     $uri = "{$type}/{$file}";
     S3::setAuth($globals['Amazon_access_key'], $globals['Amazon_secret_key']);
     $object = @S3::getObject($globals['Amazon_S3_media_bucket'], $uri, $output);
     $lastHTTPCode = $object->code;
     if ($object) {
         return $object;
     }
     // syslog(LOG_NOTICE, "Meneame, failed to get $uri from S3 to $output code: " . S3::$lastHTTPCode);
     @unlink($output);
     return false;
 }
开发者ID:manelio,项目名称:woolr,代码行数:14,代码来源:media.php

示例6: test

 /**
  * Tests S3
  *
  * @param string $error
  * @return boolean
  */
 function test(&$error)
 {
     if (!parent::test($error)) {
         return false;
     }
     $string = 'test_s3_' . md5(time());
     if (!$this->_init($error)) {
         return false;
     }
     $this->_set_error_handler();
     $buckets = @$this->_s3->listBuckets();
     if ($buckets === false) {
         $error = sprintf('Unable to list buckets (%s).', $this->_get_last_error());
         $this->_restore_error_handler();
         return false;
     }
     if (!in_array($this->_config['bucket'], (array) $buckets)) {
         $error = sprintf('Bucket doesn\'t exist: %s.', $this->_config['bucket']);
         $this->_restore_error_handler();
         return false;
     }
     if (!@$this->_s3->putObjectString($string, $this->_config['bucket'], $string, S3::ACL_PUBLIC_READ)) {
         $error = sprintf('Unable to put object (%s).', $this->_get_last_error());
         $this->_restore_error_handler();
         return false;
     }
     if (!($object = @$this->_s3->getObject($this->_config['bucket'], $string))) {
         $error = sprintf('Unable to get object (%s).', $this->_get_last_error());
         $this->_restore_error_handler();
         return false;
     }
     if ($object->body != $string) {
         $error = 'Objects are not equal.';
         @$this->_s3->deleteObject($this->_config['bucket'], $string);
         $this->_restore_error_handler();
         return false;
     }
     if (!@$this->_s3->deleteObject($this->_config['bucket'], $string)) {
         $error = sprintf('Unable to delete object (%s).', $this->_get_last_error());
         $this->_restore_error_handler();
         return false;
     }
     $this->_restore_error_handler();
     return true;
 }
开发者ID:easinewe,项目名称:Avec2016,代码行数:51,代码来源:S3.php

示例7: getFromCloud

 function getFromCloud($uri)
 {
     App::import('Vendor', 'S3', array('file' => 'S3.php'));
     $s3 = new S3($this->awsAccessKey, $this->awsSecretKey, true, "s3-ap-southeast-1.amazonaws.com");
     if (($info = $s3->getObject($this->bucketName, $uri)) !== false) {
         $path_tmp = APP . "tmp/cache/picture/";
         /*if(!is_dir($path_tmp)) {
         			mkdir(APP."tmp/cache/picture", 0777);
         		}
         		$handle = fopen($path_tmp."kossa.jpg", "w+");
         		if (fwrite($handle, $info->body) === FALSE) {
         	        echo "Cannot write to file (kossa.jpg)";
         	        exit;
         	    } else {
         		    echo "success";
         	    }*/
     }
 }
开发者ID:koprals,项目名称:coda-gosales-hsbc,代码行数:18,代码来源:GeneralComponent.php

示例8: test

 /**
  * Tests S3
  *
  * @param string $error
  * @return boolean
  */
 function test(&$error)
 {
     $string = 'test_s3_' . md5(time());
     if (!$this->_init($error)) {
         return false;
     }
     $domain = $this->get_domain();
     if (!$domain) {
         $error = 'Empty domain.';
         return false;
     }
     if (gethostbyname($domain) == $domain) {
         $error = sprintf('Unable to resolve domain: %s.', $domain);
         return false;
     }
     $buckets = @$this->_s3->listBuckets();
     if (!$buckets) {
         $error = 'Unable to list buckets (check your credentials).';
         return false;
     }
     if (!in_array($this->_config['bucket'], (array) $buckets)) {
         $error = sprintf('Bucket doesn\'t exist: %s', $this->_config['bucket']);
         return false;
     }
     if (!@$this->_s3->putObjectString($string, $this->_config['bucket'], $string, S3::ACL_PUBLIC_READ)) {
         $error = 'Unable to put object.';
         return false;
     }
     if (!($object = @$this->_s3->getObject($this->_config['bucket'], $string))) {
         $error = 'Unable to get object.';
         return false;
     }
     if ($object->body != $string) {
         @$this->_s3->deleteObject($this->_config['bucket'], $string);
         $error = 'Objects are not equal.';
         return false;
     }
     if (!@$this->_s3->deleteObject($this->_config['bucket'], $string)) {
         $error = 'Unable to delete object.';
         return false;
     }
     return true;
 }
开发者ID:alx,项目名称:SBek-Arak,代码行数:49,代码来源:S3.php

示例9: dirname

<?php

/*
CometChat
Copyright (c) 2016 Inscripts
License: https://www.cometchat.com/legal/license
*/
include_once dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . "config.php";
$file = preg_replace("/[^a-zA-Z0-9\\. ]/", "", $_GET['file']);
$file = str_replace(" ", "_", $file);
if (defined('AWS_STORAGE') && AWS_STORAGE == '1') {
    include_once dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . "functions" . DIRECTORY_SEPARATOR . "storage" . DIRECTORY_SEPARATOR . "s3.php";
    $s3 = new S3(AWS_ACCESS_KEY, AWS_SECRET_KEY);
    $filedata = $s3->getObject(AWS_BUCKET, $bucket_path . 'filetransfer/' . $file);
    $filesize = $filedata->headers['size'];
} else {
    $filepath = dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'writable' . DIRECTORY_SEPARATOR . 'filetransfer' . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . $file;
    $filedata = file_exists($filepath);
    $filesize = filesize($filepath);
}
if ($filedata) {
    header('Content-Description: File Transfer');
    header('Content-Type: application/force-download');
    header('Content-Disposition: attachment; filename=' . rawurldecode($_GET['unencryptedfilename']));
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Pragma: public');
    header('Content-Length: ' . $filesize);
    if (defined('AWS_STORAGE') && AWS_STORAGE == '1') {
        echo $filedata->body;
开发者ID:albertoneto,项目名称:localhost,代码行数:31,代码来源:download.php

示例10: downloadToPath

 public function downloadToPath($path)
 {
     //make directory.
     $dir = dirname($path);
     if (!file_exists($dir)) {
         mkdir($dir, 0777, true);
     }
     if (!is_writable($dir)) {
         return false;
     }
     //load up S3 for download
     $s3 = new S3(AMAZON_AWS_KEY, AMAZON_AWS_SECRET);
     $result = $s3->getObject($this->get('bucket'), $this->get('path'), $path);
     //did it work?
     if ($result !== false) {
         return true;
     }
     //fail :-/
     return false;
 }
开发者ID:ricberw,项目名称:BotQueue,代码行数:20,代码来源:s3file.php

示例11: hash

    }
    $hash = $msg['h'];
    $salt = hash('sha256', $salts['file_hash'] . $hash);
    $password = substr(hash('sha256', $salt . $password), 0, 20);
    if ($pw === 'false' || $pw != 'false' && $pw == $password) {
        $years_to_live = 1;
        if (isset($msg['y'])) {
            $year_to_live = $msg['y'];
        }
        $bucket_name = $aws['bucket'];
        $s3 = new S3($aws['key'], $aws['secret']);
        $year = date('y', $tx['time']);
        $month = date('m', $tx['time']);
        $day = date('d', $tx['time']);
        $location = 'paid/' . $year . '/' . $month . '/' . $day . '/' . $txid . '.' . $file_extension;
        $obj = $s3->getObject($bucket_name, $location);
        header('Content-Type: ' . $type);
        echo $obj->body;
    } else {
        echo '<form action="" method="post">';
        if ($typed_pw) {
            echo '<p><strong>Wrong Password!</strong> Please try again...</p>';
        }
        echo '<input name="password" type="password" autocomplete="off" placeholder="enter password" />';
        echo '<input type="submit" value="submit" />';
        echo '</form>';
    }
} else {
    header("HTTP/1.0 404 Not Found");
    echo '404';
}
开发者ID:habibmasuro,项目名称:hack-pack,代码行数:31,代码来源:image.php

示例12: copyqimage

function copyqimage($key, $dest)
{
    if ($GLOBALS['filehandertypecfiles'] == 's3') {
        $s3 = new S3($GLOBALS['AWSkey'], $GLOBALS['AWSsecret']);
        $s3->getObject($GLOBALS['AWSbucket'], 'qimages/' . $key, $dest);
    } else {
        $base = rtrim(dirname(dirname(__FILE__)), '/\\') . '/assessment/qimages/';
        copy($base . $key, $dest);
    }
}
开发者ID:ericvanboven,项目名称:IMathAS,代码行数:10,代码来源:filehandler.php

示例13: get_file

 public function get_file($hash)
 {
     $s3 = new S3('csub001050', 'studiomaiocchi', true, 'seewebstorage.it');
     $res = $s3->getObject('studiomaiocchistaging', $hash, false);
     return $res;
 }
开发者ID:EnricoSottile,项目名称:ammonio-sandbox,代码行数:6,代码来源:S3Service.php

示例14: backup_restore_locate_file

/**
 * make sure backup file is local, download it and make it local if necessary
 */
function backup_restore_locate_file($id, $path)
{
    global $amp_conf;
    $path = trim($path, '/');
    $path = str_replace(array('..', ':'), '', trim($path, '/'));
    $path = escapeshellcmd($path);
    $s = backup_get_server($id);
    if (!$s) {
        return array('error_msg' => _('Backup Server not found!'));
    }
    //dest is where we gona put backup files pulled infrom other servers
    $dest = $amp_conf['ASTSPOOLDIR'] . '/tmp/' . 'backuptmp-s' . $id . '-' . time() . '-' . basename($path);
    switch ($s['type']) {
        case 'local':
            $s['path'] = backup__($s['path']);
            $path = $s['path'] . '/' . $path;
            break;
        case 'ftp':
            //subsitute variables if nesesary
            $s['host'] = backup__($s['host']);
            $s['port'] = backup__($s['port']);
            $s['user'] = backup__($s['user']);
            $s['password'] = backup__($s['password']);
            $s['path'] = backup__($s['path']);
            $ftp = ftp_connect($s['host'], $s['port']);
            if (ftp_login($ftp, $s['user'], $s['password'])) {
                ftp_pasv($ftp, $s['transfer'] == 'passive');
                if (ftp_get($ftp, $dest, $s['path'] . '/' . $path, FTP_BINARY)) {
                    $path = $dest;
                } else {
                    return array('error_msg' => _('Failed to retrieve file from server!'));
                }
                ftp_close($ftp);
            } else {
                dbug('ftp connect error');
            }
            break;
        case 'ssh':
            $s['path'] = backup__($s['path']);
            $s['user'] = backup__($s['user']);
            $s['host'] = backup__($s['host']);
            $cmd[] = fpbx_which('scp');
            $cmd[] = '-o StrictHostKeyChecking=no -i';
            $cmd[] = $s['key'];
            $cmd[] = '-P ' . $s['port'];
            $cmd[] = $s['user'] . '\\@' . $s['host'] . ':' . $s['path'] . '/' . $path;
            $cmd[] = $dest;
            exec(implode(' ', $cmd), $foo, $ret);
            unset($cmd);
            if ($ret === 0) {
                $path = $dest;
            } else {
                return array('error_msg' => _('Failed to retrieve file from server!'));
            }
            break;
        case 'awss3':
            $s['bucket'] = backup__($s['bucket']);
            $s['awsaccesskey'] = backup__($s['awsaccesskey']);
            $s['awssecret'] = backup__($s['awssecret']);
            $awss3 = new S3($s['awsaccesskey'], $s['awssecret']);
            dbug('S3 Path: ' . $path);
            dbug('S3 Dest: ' . $dest);
            if ($awss3->getObject($s['bucket'], $path, $dest) !== false) {
                $path = $dest;
            } else {
                return array('error_msg' => _('Failed to retrieve file from server!'));
            }
            break;
    }
    if (file_exists($path)) {
        return $path;
    } else {
        return array('error_msg' => _('File not found! ' . $path));
    }
}
开发者ID:lidl,项目名称:backup,代码行数:78,代码来源:restore.php

示例15: array

<?php

$data = S3::getObject('resources', 'COE/sittings/' . $id . '.html');
return array('html' => @$data->body);
开发者ID:slachiewicz,项目名称:_mojePanstwo-API-Server,代码行数:4,代码来源:text.php


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