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


PHP S3Client::upload方法代码示例

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


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

示例1: createFileOnDFS

 /**
  * Creates the file $filePath on DFS with content $contents
  *
  * @param string $filePath
  * @param string $contents
  *
  * @return bool
  */
 public function createFileOnDFS($filePath, $contents)
 {
     try {
         $this->s3client->upload($this->bucket, $filePath, $contents, 'public-read');
         return true;
     } catch (S3Exception $e) {
         eZDebug::writeError($e->getMessage(), __METHOD__);
         return false;
     }
 }
开发者ID:ezsystems,项目名称:ezdfs-fsbackend-aws-s3,代码行数:18,代码来源:amazon.php

示例2: publishFile

 /**
  * Publishes the specified source file to this target, with the given relative path.
  *
  * @param resource $sourceStream
  * @param string $relativeTargetPathAndFilename
  * @param ResourceMetaDataInterface $metaData
  * @throws \Exception
  */
 protected function publishFile($sourceStream, $relativeTargetPathAndFilename, ResourceMetaDataInterface $metaData)
 {
     $objectName = $this->keyPrefix . $relativeTargetPathAndFilename;
     $options = array('ContentLength' => $metaData->getFileSize(), 'ContentType' => $metaData->getMediaType());
     try {
         $this->s3Client->upload($this->bucketName, $objectName, $sourceStream, 'public-read', $options);
         $this->systemLogger->log(sprintf('Successfully published resource as object "%s" in bucket "%s" with MD5 hash "%s"', $objectName, $this->bucketName, $metaData->getMd5() ?: 'unknown'), LOG_DEBUG);
     } catch (\Exception $e) {
         $this->systemLogger->log(sprintf('Failed publishing resource as object "%s" in bucket "%s" with MD5 hash "%s": %s', $objectName, $this->bucketName, $metaData->getMd5() ?: 'unknown', $e->getMessage()), LOG_DEBUG);
         throw $e;
     }
 }
开发者ID:revsbech,项目名称:flow-aws-s3,代码行数:20,代码来源:S3Target.php

示例3: upload

 /**
  * Upload an object.
  *
  * @param        $path
  * @param        $body
  * @param Config $config
  *
  * @return array
  */
 protected function upload($path, $body, Config $config)
 {
     $key = $this->applyPathPrefix($path);
     $options = $this->getOptionsFromConfig($config);
     $acl = isset($options['ACL']) ? $options['ACL'] : 'private';
     if (!isset($options['ContentType']) && is_string($body)) {
         $options['ContentType'] = Util::guessMimeType($path, $body);
     }
     if (!isset($options['ContentLength'])) {
         $options['ContentLength'] = is_string($body) ? Util::contentSize($body) : Util::getStreamSize($body);
     }
     $this->s3Client->upload($this->bucket, $key, $body, $acl, ['params' => $options]);
     return $this->normalizeResponse($options, $key);
 }
开发者ID:janhartigan,项目名称:flysystem-aws-s3-v3,代码行数:23,代码来源:AwsS3Adapter.php

示例4: uploadFile

 /**
  * @param string $fileName
  * @param string $fileContents
  * @return ResultInterface
  */
 public function uploadFile($fileName, $fileContents)
 {
     return $this->s3Client->upload($this->bucket, $this->basePath . "/" . $fileName, $fileContents);
 }
开发者ID:keylightberlin,项目名称:util,代码行数:9,代码来源:S3Uploader.php

示例5: store

 /**
  * @param string $fileExtension
  * @param string $data
  *
  * @return string
  */
 public function store($fileExtension, $data)
 {
     /* @var $result \Aws\Result */
     $result = $this->s3Client->upload($this->backet, uniqid() . '.' . $fileExtension, $data);
     return $result->get('ObjectURL');
 }
开发者ID:spalax,项目名称:eu-webchalange-download-images-api,代码行数:12,代码来源:AwsS3Storage.php

示例6: upload

 /**
  * upload
  *
  * @param string $key
  * @param mixed  $body
  * @param string $acl
  * @param array  $options
  *
  * @return \Guzzle\Service\Resource\Model
  */
 public function upload($key, $body, $acl = 'private', array $options = array())
 {
     return $this->client->upload($this->name, $key, $body, $acl, $options);
 }
开发者ID:m6web,项目名称:aws-bundle,代码行数:14,代码来源:Bucket.php

示例7: saveFile

 /**
  * @param string $remoteFile
  * @param string $content
  */
 function saveFile($remoteFile, $content)
 {
     $this->lastRemoteFile = $remoteFile;
     $this->s3Client->upload($this->bucket, $remoteFile, $content);
 }
开发者ID:jlaso,项目名称:aws-s3-wrapper,代码行数:9,代码来源:S3Wrapper.php

示例8: catch

    $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (Exception $e) {
    echo $e->getMessage();
    die;
}
?>
<html>
    <head><meta charset="UTF-8"></head>
    <body>
        <h1>S3 upload example</h1>
<?php 
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_FILES['userfile']) && $_FILES['userfile']['error'] == UPLOAD_ERR_OK && is_uploaded_file($_FILES['userfile']['tmp_name'])) {
    // FIXME: add more validation, e.g. using ext/fileinfo
    try {
        // FIXME: do not use 'name' for upload (that's the original filename from the user's computer)
        $upload = $s3->upload($bucket, $_FILES['userfile']['name'], fopen($_FILES['userfile']['tmp_name'], 'rb'), 'public-read');
        ?>
        <p>Upload <a href="<?php 
        echo htmlspecialchars($upload->get('ObjectURL'));
        ?>
">successful</a> :)</p>
<?php 
    } catch (Exception $e) {
        ?>
        <p>Upload error :(</p>
<?php 
    }
}
?>
        <h2>Upload a file</h2>
        <form enctype="multipart/form-data" action="<?php 
开发者ID:ehinger,项目名称:thesis,代码行数:31,代码来源:thisworks.php


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