當前位置: 首頁>>代碼示例>>PHP>>正文


PHP S3Client::get方法代碼示例

本文整理匯總了PHP中Aws\S3\S3Client::get方法的典型用法代碼示例。如果您正苦於以下問題:PHP S3Client::get方法的具體用法?PHP S3Client::get怎麽用?PHP S3Client::get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Aws\S3\S3Client的用法示例。


在下文中一共展示了S3Client::get方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: uri

 /**
  * Return the web-accessible uri for the given file.
  *
  * @param  string            $file
  * @return string            The file uri
  * @throws \RuntimeException
  */
 public function uri($file)
 {
     if (null !== $this->filenameFilter) {
         $file = $this->filenameFilter->filter($file);
     }
     try {
         $request = $this->s3Client->get($this->getBucket() . '/' . $file);
         return $this->s3Client->getPresignedUrl($request, $this->getUriExpirationTime());
     } catch (S3Exception $e) {
         if (!$this->getThrowExceptions()) {
             return null;
         }
         throw new \RuntimeException('Exception thrown by Aws\\S3\\S3Client: ' . $e->getMessage(), null, $e);
     }
 }
開發者ID:dotsunited,項目名稱:cabinet,代碼行數:22,代碼來源:AmazonS3Adapter.php

示例2: testPreSignedUrlAllowsSpecialCharacters

 /**
  * @depends testPutAndListObjects
  */
 public function testPreSignedUrlAllowsSpecialCharacters()
 {
     self::log('Uploading an object with a space in the key');
     $this->client->waitUntil('bucket_exists', array('Bucket' => $this->bucket));
     $key = 'foo baz bar!';
     $this->client->putObject(array('Bucket' => $this->bucket, 'Key' => $key, 'Body' => 'hi'));
     $this->client->waitUntil('object_exists', array('Bucket' => $this->bucket, 'Key' => $key));
     self::log('Creating an downloading using a pre-signed URL');
     $extra = urlencode("attachment; filename=\"{$key}\"");
     $request = $this->client->get("{$this->bucket}/{$key}?response-content-disposition={$extra}");
     $url = $this->client->createPresignedUrl($request, '+10 minutes');
     self::log($url);
     $client = new Client();
     $this->assertEquals('hi', file_get_contents($url));
     $this->assertEquals('hi', $client->get($url)->send()->getBody(true));
 }
開發者ID:noahkim,項目名稱:kowop,代碼行數:19,代碼來源:IntegrationTest.php


注:本文中的Aws\S3\S3Client::get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。