Example #1
0
 /**
  * Duplicate temporary images
  *
  * @param string $file
  * @return string
  */
 public function duplicateImageFromTmp($file)
 {
     $file = $this->getFilenameFromTmp($file);
     $destinationFile = $this->_getUniqueFileName($file, true);
     if ($this->_fileStorageDb->checkDbUsage()) {
         $this->_fileStorageDb->copyFile($this->_mediaDirectory->getAbsolutePath($this->_mediaConfig->getTmpMediaShortUrl($file)), $this->_mediaConfig->getTmpMediaShortUrl($destinationFile));
     } else {
         $this->_mediaDirectory->copyFile($this->_mediaConfig->getTmpMediaPath($file), $this->_mediaConfig->getTmpMediaPath($destinationFile));
     }
     return str_replace('\\', '/', $destinationFile);
 }
Example #2
0
 /**
  * Move image from temporary directory to normal
  *
  * @param string $file
  * @return string
  */
 protected function moveImageFromTmp($file)
 {
     $file = $this->getFilenameFromTmp($file);
     $destinationFile = $this->getUniqueFileName($file);
     if ($this->fileStorageDb->checkDbUsage()) {
         $this->fileStorageDb->renameFile($this->mediaConfig->getTmpMediaShortUrl($file), $this->mediaConfig->getMediaShortUrl($destinationFile));
         $this->mediaDirectory->delete($this->mediaConfig->getTmpMediaPath($file));
         $this->mediaDirectory->delete($this->mediaConfig->getMediaPath($destinationFile));
     } else {
         $this->mediaDirectory->renameFile($this->mediaConfig->getTmpMediaPath($file), $this->mediaConfig->getMediaPath($destinationFile));
     }
     return str_replace('\\', '/', $destinationFile);
 }
Example #3
0
 /**
  * move image from tmp to catalog dir
  *
  * @param string $file
  * @return string path
  */
 public function moveImageFromTmp($file)
 {
     if (strrpos($file, '.tmp') == strlen($file) - 4) {
         $file = substr($file, 0, strlen($file) - 4);
     }
     $destinationFile = $this->getUniqueFileName($file);
     /** @var $storageHelper \Magento\MediaStorage\Helper\File\Storage\Database */
     $storageHelper = $this->fileStorageDb;
     if ($storageHelper->checkDbUsage()) {
         $storageHelper->renameFile($this->mediaConfig->getTmpMediaShortUrl($file), $this->mediaConfig->getMediaShortUrl($destinationFile));
         $this->mediaDirectory->delete($this->mediaConfig->getTmpMediaPath($file));
         $this->mediaDirectory->delete($this->getAttributeSwatchPath($destinationFile));
     } else {
         $this->mediaDirectory->renameFile($this->mediaConfig->getTmpMediaPath($file), $this->getAttributeSwatchPath($destinationFile));
     }
     return str_replace('\\', '/', $destinationFile);
 }