本文整理汇总了PHP中Aws\S3\S3Client::getObjectUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP S3Client::getObjectUrl方法的具体用法?PHP S3Client::getObjectUrl怎么用?PHP S3Client::getObjectUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Aws\S3\S3Client
的用法示例。
在下文中一共展示了S3Client::getObjectUrl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: resolveUrlFor
/**
* @param $path
* @return string
*/
public function resolveUrlFor($path)
{
$path = trim($this->prefix, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . ltrim($path, DIRECTORY_SEPARATOR);
return $this->client->getObjectUrl($this->bucket, $path);
}
示例2: getObjectUrl
/**
* getObjectUrl
*
* @param string $key
* @param mixed $expires
* @param array $params
*
* @return string
*/
public function getObjectUrl($key, $expires = null, array $params = array())
{
return $this->client->getObjectUrl($this->name, $key, $expires, $params);
}
示例3: getObjectUrl
/**
* Returns the URL to an object identified by its bucket and key.
*
* The URL returned by this method is not signed nor does it ensure the the
* bucket and key given to the method exist. If you need a signed URL, then
* use the {@see \Aws\S3\S3Client::createPresignedRequest} method and get
* the URI of the signed request.
*
* @param string $bucket The name of the bucket where the object is located
* @param string $key The key of the object
*
* @return string The URL to the object
*/
public function getObjectUrl($site, $key)
{
$config = $this->_config;
$bucket = $config['bucket'];
$builtBucket = strlen($bucket) > 0 ? $site . '.' . $bucket : $site;
return $this->_s3Client->getObjectUrl($builtBucket, $key);
}
示例4: getUrl
/**
* {@inheritdoc}
*/
public function getUrl($filename)
{
$path = $filename;
if ($this->directory) {
$path = sprintf('%s/%s', $this->directory, $path);
}
return $this->client->getObjectUrl($this->bucket, $path);
}
示例5: uploadHtml
/**
* @param string $html the content to be uploaded.
* @return string the URL of the uploaded content.
*/
public function uploadHtml($headers, $html)
{
$file = date('YmdHis-') . uniqid("", true);
$key = (!empty($this->directoryPath) ? $this->directoryPath . '/' : '') . $file . '.html';
$url = $this->_client->getObjectUrl($this->bucket, $key);
$result = $this->_client->putObject(array_merge(['ACL' => 'public-read', 'Bucket' => $this->bucket, 'Body' => str_replace($this->archiveUrlTag, $url, $html), 'CacheControl' => 'max-age=31536000, public', 'ContentType' => 'text/html', 'Key' => $key, 'Metadata' => ['X-UID-MailHeader' => \yii\helpers\Json::encode($headers)], 'Expires' => gmdate('D, d M Y H:i:s \\G\\M\\T', strtotime('+5 year'))], $this->uploadOptions));
if ($result) {
return $url;
} else {
return false;
}
}
示例6: find
/**
* {@inheritDoc}
*/
public function find($path)
{
$s3Url = $this->client->getObjectUrl($this->bucket, trim($this->prefix, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . ltrim($path, DIRECTORY_SEPARATOR));
if (false == @getimagesize($s3Url)) {
return $this->fallbackLoader->find($path);
}
$tmpFilePath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . basename($s3Url);
file_put_contents($tmpFilePath, file_get_contents($s3Url));
$mimeType = $this->mimeTypeGuesser->guess($tmpFilePath);
unlink($tmpFilePath);
return new Binary(file_get_contents($s3Url), $mimeType, $this->extensionGuesser->guess($mimeType));
}
示例7: getTokenUrl
/**
* @param $file_contenthash
* @param $file_statusamazon
* @return string
*/
public function getTokenUrl($file_contenthash, $file_statusamazon)
{
$fileRelativeLocation = substr($this->path_from_hash($file_contenthash), 1);
if (!class_exists('S3Util')) {
require_once __DIR__ . '/S3Util.php';
}
$file = S3Util::getPrefix() . $fileRelativeLocation;
if ($file_statusamazon == 'public') {
return S3Util::getS3Url() . $fileRelativeLocation;
}
return $this->client->getObjectUrl($this->bucket_name, $file, '+5 minutes');
}
示例8: __invoke
/**
* Create a link to a S3 object from a bucket. If expiration is not empty, then it is used to create
* a signed URL
*
* @param string $object The object name (full path)
* @param string $bucket The bucket name
* @param string|int $expiration The Unix timestamp to expire at or a string that can be evaluated by strtotime
* @throws InvalidDomainNameException
* @return string
*/
public function __invoke($object, $bucket = '', $expiration = '')
{
$bucket = trim($bucket ?: $this->getDefaultBucket(), '/');
if (empty($bucket)) {
throw new InvalidDomainNameException('An empty bucket name was given');
}
if ($expiration) {
$command = $this->client->getCommand('GetObject', ['Bucket' => $bucket, 'Key' => $object]);
return $this->client->createPresignedRequest($command, $expiration)->getUri()->__toString();
} else {
return $this->client->getObjectUrl($bucket, $object);
}
}
示例9: getPublicPersistentResourceUri
/**
* Returns the web accessible URI pointing to the specified persistent resource
*
* @param \TYPO3\Flow\Resource\Resource $resource Resource object or the resource hash of the resource
* @return string The URI
* @throws Exception
*/
public function getPublicPersistentResourceUri(Resource $resource)
{
if ($this->baseUri != '') {
return $this->baseUri . $this->getRelativePublicationPathAndFilename($resource, TRUE);
} else {
return $this->s3Client->getObjectUrl($this->bucketName, $this->keyPrefix . $this->getRelativePublicationPathAndFilename($resource, TRUE));
}
}
示例10: find
/**
* @param $namespace
* @param $filter
* @return array
*/
public function find($namespace, $filter)
{
$pattern = self::buildPattern($filter);
$iterator = $this->s3Client->getIterator('ListObjects', ['Bucket' => $this->basePath, 'Prefix' => Utils::normalizePath($this->relativePath . '/' . $namespace)]);
$results = [];
foreach ($iterator as $object) {
if (!$pattern || preg_match($pattern, '/' . strtr($object['Key'], '\\', '/'))) {
$url = $this->s3Client->getObjectUrl($this->basePath, $object['Key']);
$results[$url] = new \SplFileInfo($url);
}
}
return $results;
}
示例11: getFileUrl
/**
* @inheritdoc
*/
public function getFileUrl(File $file, array $options)
{
return $this->client->getObjectUrl($this->bucket, $this->createFilePath($file));
}
示例12: getObjectUrl
/**
* Returns the URL for an object saved on Amazon S3.
*
* @param string $path
*
* @return string
*/
protected function getObjectUrl($path)
{
return $this->storage->getObjectUrl($this->bucket, $path, 0, $this->getOptions);
}
示例13: url
/**
* Return the url for a file upload.
*
* @param string $styleName
*
* @return string
*/
public function url($styleName)
{
return $this->s3Client->getObjectUrl($this->attachedFile->s3_object_config['Bucket'], $this->path($styleName), null, ['PathStyle' => true]);
}
示例14: getUrl
/**
* Get remote url, return false in case of error
*
* @param string $path Remote Path with folder
*
* @return string
*/
public function getUrl($path)
{
return $this->clientS3->getObjectUrl($this->bucket, $path);
}
示例15: getUrl
/**
* @param $key
* @return mixed
*/
public function getUrl($key)
{
$this->service->getObjectUrl($this->bucket, $key);
}