Exemplo n.º 1
0
 /**
  * Create presigned URLs for an object with temporary credentials
  *
  * @depends testGetObjectUrl
  * @example Mss\S3\S3Client::getObjectUrl
  */
 public function testGetObjectUrlWithSessionCredentials()
 {
     $this->client->waitUntil('BucketExists', array('Bucket' => $this->bucket));
     $bucket = $this->bucket;
     /** @var $stsClient \Mss\Sts\StsClient */
     $stsClient = $this->getServiceBuilder()->get('sts');
     // @begin
     // Create a credentials object using temporary credentials retrieved from STS
     $tempCredentials = $stsClient->createCredentials($stsClient->getSessionToken());
     // Create an S3 client using the temporary credentials
     $s3Client = \Mss\S3\S3Client::factory()->setCredentials($tempCredentials);
     // Get a presigned URL for an Amazon S3 object
     $signedUrl = $s3Client->getObjectUrl($bucket, 'data.txt', '+10 minutes');
     echo file_get_contents($signedUrl);
     // > Hello!
     // @end
     $this->assertEquals('Hello!', $this->getActualOutput());
 }
Exemplo n.º 2
0
 public function no_testUsesSigV4SignatureInSpecificRegions()
 {
     $s3 = S3Client::factory(array(Options::REGION => 'cn-north-1'));
     $this->assertInstanceOf('Mss\\S3\\S3SignatureV4', $s3->getSignature());
 }