本文整理汇总了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;
}
}
示例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;
}
}
示例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);
}
示例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);
}
示例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');
}
示例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);
}
示例7: saveFile
/**
* @param string $remoteFile
* @param string $content
*/
function saveFile($remoteFile, $content)
{
$this->lastRemoteFile = $remoteFile;
$this->s3Client->upload($this->bucket, $remoteFile, $content);
}
示例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