public function testUploadAndDeleteArchives() { $length = 6 * Size::MB + 425; $content = EntityBody::factory(str_repeat('x', $length)); $partSize = 2 * Size::MB; // Single upload $archiveId = $this->client->getCommand('UploadArchive', array('vaultName' => self::TEST_VAULT, 'archiveDescription' => 'Foo bar', 'body' => $content))->getResult()->get('archiveId'); $this->assertNotEmpty($archiveId); // Delete the archive $this->client->deleteArchive(array('vaultName' => self::TEST_VAULT, 'archiveId' => $archiveId)); sleep(3); // Multipart upload $generator = UploadPartGenerator::factory($content, $partSize); $this->assertEquals($length, $generator->getArchiveSize()); $uploadId = $this->client->getCommand('InitiateMultipartUpload', array('vaultName' => self::TEST_VAULT, 'partSize' => (string) $partSize))->getResult()->get('uploadId'); /** @var $part UploadPart */ foreach ($generator as $part) { $this->client->uploadMultipartPart(array('vaultName' => self::TEST_VAULT, 'uploadId' => $uploadId, 'range' => $part->getFormattedRange(), 'checksum' => $part->getChecksum(), 'ContentSHA256' => $part->getContentHash(), 'body' => new ReadLimitEntityBody($content, $part->getSize(), $part->getOffset()))); sleep(3); } $archiveId = $this->client->getCommand('CompleteMultipartUpload', array('vaultName' => self::TEST_VAULT, 'uploadId' => $uploadId, 'archiveSize' => $generator->getArchiveSize(), 'checksum' => $generator->getRootChecksum()))->getResult()->get('archiveId'); $this->assertNotEmpty($archiveId); // Delete the archive $this->client->deleteArchive(array('vaultName' => self::TEST_VAULT, 'archiveId' => $archiveId)); }