public function testMultipartUpload() { $this->client->waitUntil('bucket_exists', array('Bucket' => $this->bucket)); self::log('Creating a 100MB object in /tmp/large-object.jpg'); $handle = fopen('/tmp/large-object.jpg', 'w+'); $part = str_repeat('.', 1000); for ($i = 0; $i < 1024 * 1024 * 5 / 1000; $i++) { fwrite($handle, $part); } fclose($handle); $history = new HistoryPlugin(); $this->client->addSubscriber($history); self::log('Initiating transfer'); $transfer = UploadBuilder::newInstance()->setBucket($this->bucket)->setKey('large_key')->setSource(self::LARGE_OBJECT)->calculateMd5(true)->calculatePartMd5(true)->setOption('ACL', 'public-read')->setClient($this->client)->build(); $this->assertEquals(1, $history->count()); $this->assertTrue($history->getLastRequest()->getQuery()->hasKey('uploads')); $this->assertEquals('image/jpeg', (string) $history->getLastRequest()->getHeader('Content-Type')); $history->clear(); self::log('Uploading parts'); $transfer->upload(); $this->assertEquals(3, $history->count()); $requests = $history->getIterator()->getArrayCopy(); $this->assertEquals('PUT', $requests[0]->getMethod()); $this->assertEquals('PUT', $requests[1]->getMethod()); $this->assertEquals('POST', $requests[2]->getMethod()); }