Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 protected function initiateMultipartUpload()
 {
     $params = array('Bucket' => $this->bucket, 'Key' => $this->key);
     $command = $this->client->getCommand('CreateMultipartUpload', array_replace($params, array('command.headers' => $this->headers, 'ACP' => $this->acp, Ua::OPTION => Ua::MULTIPART_UPLOAD)));
     // Calculate the MD5 hash if none was set and it is asked of the builder
     if ($this->calculateEntireMd5) {
         $this->md5 = $this->source->getContentMd5();
     }
     // If an MD5 is specified, then add it to the custom headers of the request
     // so that it will be returned when downloading the object from Amazon S3
     if ($this->md5) {
         $command['Metadata'] = array('x-amz-Content-MD5' => $this->md5);
     }
     $result = $command->execute();
     // Create a new state based on the initiated upload
     $params['UploadId'] = $result['UploadId'];
     return new TransferState(UploadId::fromParams($params));
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 protected function initiateMultipartUpload()
 {
     // Determine Content-Type
     if ($mimeType = $this->source->getContentType()) {
         $this->commandOptions['ContentType'] = $mimeType;
     }
     $params = array_replace(array(Ua::OPTION => Ua::MULTIPART_UPLOAD, 'command.headers' => $this->headers, 'Metadata' => array()), $this->commandOptions);
     // Calculate the MD5 hash if none was set and it is asked of the builder
     if ($this->calculateEntireMd5) {
         $this->md5 = $this->source->getContentMd5();
     }
     // If an MD5 is specified, then add it to the custom headers of the request
     // so that it will be returned when downloading the object from Amazon S3
     if ($this->md5) {
         $params['Metadata']['x-amz-Content-MD5'] = $this->md5;
     }
     $result = $this->client->getCommand('CreateMultipartUpload', $params)->execute();
     // Create a new state based on the initiated upload
     $params['UploadId'] = $result['UploadId'];
     return new TransferState(UploadId::fromParams($params));
 }
Exemplo n.º 3
0
 public function testBuildsDifferentUploaderBasedOnConcurrency()
 {
     $state = new TransferState(UploadId::fromParams(array('Bucket' => 'foo', 'Key' => 'bar', 'UploadId' => 'baz')));
     $b = UploadBuilder::newInstance()->setClient($this->getServiceBuilder()->get('s3'))->setSource(EntityBody::factory(fopen(__FILE__, 'r')))->resumeFrom($state);
     $this->assertInstanceOf('Aws\\S3\\Model\\MultipartUpload\\SerialTransfer', $b->build());
     $b->setConcurrency(2);
     $this->assertInstanceOf('Aws\\S3\\Model\\MultipartUpload\\ParallelTransfer', $b->build());
 }