/**
  * @param ResourceInterface $resource
  * @param GaufretteFile $file
  * @throws \InvalidArgumentException|\UnexpectedValueException|FileNotFound
  */
 public function updateResourceMetadata(ResourceInterface $resource, GaufretteFile $file)
 {
     if ($resource instanceof Document) {
         $mimeType = $file->getMimeType();
         if (!$mimeType) {
             $finfo = new \finfo(FILEINFO_MIME_TYPE);
             $mimeType = $finfo->buffer($file->getContent());
         }
         $resource->setFileModifiedAt($file->getMtime())->setFileSize($file->getSize())->setFileType($mimeType);
     }
     if ($resource instanceof Image) {
         $imageSize = getimagesizefromstring($file->getContent());
         $resource->setWidth(isset($imageSize[0]) ? $imageSize[0] : null)->setHeight(isset($imageSize[1]) ? $imageSize[1] : null);
     }
 }
 /**
  * @param ResourceInterface $resource
  * @return Filesystem
  * @throws UnexpectedValueException
  */
 public function getFilesystem(ResourceInterface $resource)
 {
     return $this->getFilesystemForType($resource->getType());
 }