public function testCanCreateNewStateByInitiatingMultipartUpload()
 {
     $acl = new Acp(new Grantee('123'));
     $acl->addGrant(new Grant(new Grantee('123'), Permission::READ));
     $client = $this->getServiceBuilder()->get('s3');
     $mock = $this->setMockResponse($client, array('s3/initiate_multipart_upload'));
     $transfer = UploadBuilder::newInstance()->setBucket('foo')->setKey('bar')->setClient($client)->setSource(EntityBody::factory())->setHeaders(array('Foo' => 'Bar'))->setAcp($acl)->calculateMd5(true)->build();
     $requests = $mock->getReceivedRequests();
     $this->assertEquals(1, count($requests));
     $this->assertEquals('/bar?uploads', $requests[0]->getResource());
     $this->assertEquals('Bar', (string) $requests[0]->getHeader('Foo'));
     $this->assertTrue($requests[0]->hasHeader('x-amz-grant-read'));
 }
Ejemplo n.º 2
0
 public function testCanCreateNewStateByInitiatingMultipartUpload()
 {
     $acl = new Acp(new Grantee('123'));
     $acl->addGrant(new Grant(new Grantee('123'), Permission::READ));
     $client = $this->getServiceBuilder()->get('s3');
     $mock = $this->setMockResponse($client, array('s3/initiate_multipart_upload'));
     $expires = time() + 1000;
     $transfer = UploadBuilder::newInstance()->setBucket('foo')->setKey('bar')->setClient($client)->setSource(__FILE__)->setHeaders(array('Foo' => 'Bar'))->setOption('Expires', $expires)->setAcp($acl)->calculateMd5(true)->build();
     $requests = $mock->getReceivedRequests();
     $this->assertEquals(1, count($requests));
     $this->assertEquals('/bar?uploads', $requests[0]->getResource());
     $this->assertEquals('Bar', (string) $requests[0]->getHeader('Foo'));
     $this->assertEquals($expires, strtotime((string) $requests[0]->getHeader('Expires')));
     $this->assertEquals('text/x-php', (string) $requests[0]->getHeader('Content-Type'));
     $this->assertNotEmpty((string) $requests[0]->getHeader('x-amz-meta-x-amz-Content-MD5'));
     $this->assertEquals('id="123"', (string) $requests[0]->getHeader('x-amz-grant-read'));
     $this->assertTrue($requests[0]->hasHeader('x-amz-grant-read'));
 }