/**
  * {@inheritdoc}
  */
 protected function initiateMultipartUpload()
 {
     // Determine Content-Type
     if (!isset($this->commandOptions['ContentType'])) {
         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));
 }
 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('Mss\\S3\\Model\\MultipartUpload\\SerialTransfer', $b->build());
     $b->setConcurrency(2);
     $this->assertInstanceOf('Mss\\S3\\Model\\MultipartUpload\\ParallelTransfer', $b->build());
 }