コード例 #1
0
ファイル: PostFileTest.php プロジェクト: hexcode007/yfcms
 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']);
 }
コード例 #2
0
 /**
  * @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;
 }
コード例 #3
0
ファイル: ClientTest.php プロジェクト: b-sebastian/timetable
 protected function assertFile(PostFile $postFile, $fieldName, $fileName, $headers)
 {
     $this->assertEquals($postFile->getName(), $fieldName);
     $this->assertEquals($postFile->getFilename(), $fileName);
     $this->assertEquals($postFile->getHeaders(), $headers);
 }
コード例 #4
0
ファイル: ClientTest.php プロジェクト: brennantom/hackazon
 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);
 }