protected function applyNamer(MediaInterface $media)
 {
     if ($media->getName() !== null) {
         return false;
     }
     $name = $this->namer->getName($media->getFile());
     $media->setName($name);
     return true;
 }
Example #2
0
 /**
  * Uploads the file.
  *
  * @param MediaInterface $media
  */
 public function upload(MediaInterface $media)
 {
     $file = $media->getFile();
     if (!$file instanceof UploadedFile) {
         return;
     }
     $this->filesystem->write($media->getPath(), file_get_contents($file->getFileInfo()->getPathname()));
     // Mark as null to not upload again
     $media->setFile(null);
 }