Ejemplo n.º 1
0
 /**
  * @param FileObject $file
  * @param Response $response
  */
 protected function injectContentToResponse(FileObject $file, Response $response)
 {
     $response->setContent(function () use($file) {
         return file_get_contents($file->getRealPath());
     });
 }
Ejemplo n.º 2
0
 /**
  * Returns the mimetype of a version provided by this plugin via retrieving and inspecting.
  * More specific plugins should override this for performance.
  *
  * @param File $file
  * @param Version $version
  * @return string
  */
 public function getMimeType(File $file, Version $version)
 {
     $retrieved = $this->storage->retrieveVersion($this->getApplicableVersionable($file), $version);
     $fileObj = new FileObject($retrieved);
     return $fileObj->getMimeType();
 }
Ejemplo n.º 3
0
 /**
  * @test
  */
 public function returnsMimeType()
 {
     $fileObj = new FileObject(ROOT_TESTS . '/data/self-lussing-manatee.jpg');
     $this->assertEquals('image/jpeg', $fileObj->getMimeType());
 }
Ejemplo n.º 4
0
 /**
  * Deletes on destruct if temporary
  */
 public function __destruct()
 {
     if ($this->isTemporary()) {
         unlink($this->fileObject->getRealPath());
     }
 }