public function testGettersAndSetters()
 {
     $uploadId = $this->getMock('Aws\\Glacier\\Model\\MultipartUpload\\UploadId');
     $generator = $this->getMockBuilder('Aws\\Glacier\\Model\\MultipartUpload\\UploadPartGenerator')->disableOriginalConstructor()->getMock();
     $state = new TransferState($uploadId);
     $state->setPartGenerator($generator);
     $this->assertSame($generator, $state->getPartGenerator());
 }
 protected function prepComponents()
 {
     $uploadId = $this->getMockUploadId();
     $body = EntityBody::factory(fopen(__FILE__, 'r'));
     $generator = SpecialUploadPartGenerator::factory($body, 1024 * 1024);
     $client = $this->getServiceBuilder()->get('glacier', true);
     $state = new TransferState($uploadId);
     $state->setPartGenerator($generator);
     $transfer = new ParallelTransfer($client, $state, $body, array('concurrency' => 2));
     return array($transfer, $client, $state);
 }
 protected function prepComponents()
 {
     $uploadId = $this->getMockBuilder('Aws\\Glacier\\Model\\MultipartUpload\\UploadId')->setMethods(array('toParams'))->getMock();
     $uploadId->expects($this->any())->method('toParams')->will($this->returnValue(array('accountId' => '-', 'vaultName' => 'foo', 'uploadId' => 'bar')));
     $body = EntityBody::factory(str_repeat('x', 1024 * 1024 + 1024));
     $generator = UploadPartGenerator::factory($body, 1024 * 1024);
     $client = $this->getServiceBuilder()->get('glacier', true);
     $state = new TransferState($uploadId);
     $state->setPartGenerator($generator);
     $transfer = new SerialTransfer($client, $state, $body);
     return array($transfer, $client, $state);
 }
 public function testBuildsDifferentUploaderBasedOnConcurrency()
 {
     $generator = $this->getMockBuilder('Aws\\Glacier\\Model\\MultipartUpload\\UploadPartGenerator')->setMethods(array('getPartSize'))->disableOriginalConstructor()->getMock();
     $generator->expects($this->any())->method('getPartSize')->will($this->returnValue(1024 * 1024));
     $state = new TransferState(UploadId::fromParams(array('accountId' => 'foo', 'vaultName' => 'baz', 'uploadId' => 'bar')));
     $state->setPartGenerator($generator);
     $b = UploadBuilder::newInstance()->setVaultName('foo')->setPartGenerator($generator)->setClient($this->getServiceBuilder()->get('glacier'))->resumeFrom($state)->setSource(EntityBody::factory(fopen(__FILE__, 'r')));
     $this->assertInstanceOf('Aws\\Glacier\\Model\\MultipartUpload\\SerialTransfer', $b->build());
     $b->setConcurrency(2);
     $this->assertInstanceOf('Aws\\Glacier\\Model\\MultipartUpload\\ParallelTransfer', $b->build());
 }
Пример #5
0
 /**
  * {@inheritdoc}
  */
 protected function initiateMultipartUpload()
 {
     $params = array('accountId' => $this->accountId, 'vaultName' => $this->vaultName);
     $partGenerator = $this->partGenerator ?: UploadPartGenerator::factory($this->source, $this->partSize);
     $command = $this->client->getCommand('InitiateMultipartUpload', array_replace($params, array('command.headers' => $this->headers, 'partSize' => $partGenerator->getPartSize(), 'archiveDescription' => $this->archiveDescription, Ua::OPTION => Ua::MULTIPART_UPLOAD)));
     $params['uploadId'] = $command->getResult()->get('uploadId');
     // Create a new state based on the initiated upload
     $state = new TransferState(UploadId::fromParams($params));
     $state->setPartGenerator($partGenerator);
     return $state;
 }