public function testFromUploadIdFactoryWorks() { $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'))); $client = $this->getServiceBuilder()->get('glacier'); $mock = $this->setMockResponse($client, array('glacier/list_parts')); $state = TransferState::fromUploadId($client, $uploadId); $this->assertInstanceOf('Aws\\Glacier\\Model\\MultipartUpload\\TransferState', $state); $this->assertEquals(1, count($mock->getReceivedRequests())); }
/** * {@inheritdoc} * @throws InvalidArgumentException when attempting to resume a transfer using a non-seekable stream * @throws InvalidArgumentException when missing required properties (bucket, key, client, source) */ public function build() { // If a Glacier upload helper object was set, use the source and part size from it if ($this->partGenerator) { $this->partSize = $this->partGenerator->getPartSize(); } if (!$this->state instanceof State && !$this->vaultName || !$this->client || !$this->source) { throw new InvalidArgumentException('You must specify a vault name, client, and source.'); } if (!$this->source->isSeekable()) { throw new InvalidArgumentException('You cannot upload from a non-seekable source.'); } // If no state was set, then create one by initiating or loading a multipart upload if (is_string($this->state)) { if (!$this->partGenerator) { throw new InvalidArgumentException('You must provide an UploadPartGenerator when resuming an upload.'); } /** @var $state \Aws\Glacier\Model\MultipartUpload\TransferState */ $this->state = TransferState::fromUploadId($this->client, UploadId::fromParams(array('accountId' => $this->accountId, 'vaultName' => $this->vaultName, 'uploadId' => $this->state))); $this->state->setPartGenerator($this->partGenerator); } elseif (!$this->state) { $this->state = $this->initiateMultipartUpload(); } $options = array('concurrency' => $this->concurrency); return $this->concurrency > 1 ? new ParallelTransfer($this->client, $this->state, $this->source, $options) : new SerialTransfer($this->client, $this->state, $this->source, $options); }