public function testCanAddHeaders() { $p = new PostFile('foo', Stream::factory('hi'), 'test.php', ['X-Foo' => '123', 'Content-Disposition' => 'bar']); $this->assertEquals('bar', $p->getHeaders()['Content-Disposition']); $this->assertEquals('123', $p->getHeaders()['X-Foo']); }
/** * @param Container $container * @param File $file * * @return RequestInterface * @throws \ForumHouse\SelectelStorageApi\Exception\UnexpectedError */ protected function createRequestUploadFile(Container $container, File $file) { $request = $this->createHttpRequest('put', $container, $file); /** @var PostBodyInterface $postBody */ $postFile = new PostFile(basename($file->getLocalName()), $file->openLocal('r')); $body = $postFile->getContent(); $request->setBody($body); $request->addHeaders($file->getHeaders()); return $request; }
protected function assertFile(PostFile $postFile, $fieldName, $fileName, $headers) { $this->assertEquals($postFile->getName(), $fieldName); $this->assertEquals($postFile->getFilename(), $fileName); $this->assertEquals($postFile->getHeaders(), $headers); }
protected function assertFile(PostFile $postFile, $fieldName, $fileName, $headers) { $this->assertEquals($postFile->getName(), $fieldName); $this->assertEquals($postFile->getFilename(), $fileName); $postFileHeaders = $postFile->getHeaders(); // Note: Sort 'Content-Disposition' values before comparing, because the order changed in Guzzle 4.2.2 $postFileHeaders['Content-Disposition'] = explode('; ', $postFileHeaders['Content-Disposition']); sort($postFileHeaders['Content-Disposition']); $headers['Content-Disposition'] = explode('; ', $headers['Content-Disposition']); sort($headers['Content-Disposition']); $this->assertEquals($postFileHeaders, $headers); }