Example #1
0
 /**
  * Stores a binary file and returns it's new relative file name
  *
  * @param \Aimeos\MW\Media\Iface $mediaFile Media object
  * @param string $type Type of the image like "preview" or "files"
  * @param string $filename Name of the new file without file extension
  * @param string Name of the file system to store the files at
  * @return string Relative path to the new file
  * @throws \Aimeos\Controller\Common\Exception If an error occurs
  */
 protected function storeFile(\Aimeos\MW\Media\Iface $mediaFile, $type, $filename, $fsname)
 {
     $file = $mediaFile->getFilepath();
     $fileext = $this->getFileExtension($mediaFile->getMimetype());
     $dest = "{$type}/{$filename[0]}/{$filename[1]}/{$filename}{$fileext}";
     $this->context->getFilesystemManager()->get($fsname)->writef($dest, $file);
     return $dest;
 }