public function saveFileToTmpDir($fileId)
    {
        $baseTmpPath = $this->getBaseTmpPath();

        $uploader = $this->uploaderFactory->create(['fileId' => $fileId]);
        $uploader->setAllowedExtensions($this->getAllowedExtensions());
        $uploader->setAllowRenameFiles(true);
        $uploader->setFilesDispersion(true);

        $result = $uploader->save($this->mediaDirectory->getAbsolutePath($baseTmpPath));

        if (!$result) {
            throw new LocalizedException(
                __('File can not be saved to the destination folder.')
            );
        }
        /**
         * Workaround for prototype 1.7 methods "isJSON", "evalJSON" on Windows OS
         */
        $result['tmp_name'] = str_replace('\\', '/', $result['tmp_name']);
        $result['path'] = str_replace('\\', '/', $result['path']);
        $result['url'] =  $this->getBaseUrl() . $this->getFilePath($baseTmpPath, $result['file']);

        if (isset($result['file'])) {
            try {
                $relativePath = rtrim($baseTmpPath, '/') . '/' . ltrim($result['file'], '/');
                $this->coreFileStorageDatabase->saveFile($relativePath);
            } catch (\Exception $e) {
                $this->logger->critical($e);
                throw new LocalizedException(
                    __('Something went wrong while saving the file(s).')
                );
            }
        }

        return $result;
    }
public function saveFileToTmpDir($fileId)
    {
        $baseTmpPath = $this->getBaseTmpPath();

        $uploader = $this->uploaderFactory->create(['fileId' => $fileId]);
        $uploader->setAllowedExtensions($this->getAllowedExtensions());
        $uploader->setAllowRenameFiles(true);
        $uploader->setFilesDispersion(true);

        $result = $uploader->save($this->mediaDirectory->getAbsolutePath($baseTmpPath));

        if (!$result) {
            throw new LocalizedException(
                __('File can not be saved to the destination folder.')
            );
        }
        /**
         * Workaround for prototype 1.7 methods "isJSON", "evalJSON" on Windows OS
         */
        $result['tmp_name'] = str_replace('\\', '/', $result['tmp_name']);
        $result['path'] = str_replace('\\', '/', $result['path']);
        $result['url'] =  $this->getBaseUrl() . $this->getFilePath($baseTmpPath, $result['file']);

        if (isset($result['file'])) {
            try {
                $relativePath = rtrim($baseTmpPath, '/') . '/' . ltrim($result['file'], '/');
                $this->coreFileStorageDatabase->saveFile($relativePath);
            } catch (\Exception $e) {
                $this->logger->critical($e);
                throw new LocalizedException(
                    __('Something went wrong while saving the file(s).')
                );
            }
        }

        return $result;
    }
public function saveFileToTmpDir ( $ fileId ) { $ baseTmpPath = $ this -> getBaseTmpPath ( ) ; $ uploader = $ this -> uploaderFactory -> create ( [ 'fileId' => $ fileId ] ) ; $ uploader -> setAllowedExtensions ( $ this -> getAllowedExtensions ( ) ) ; $ uploader -> setAllowRenameFiles ( true ) ; $ uploader -> setFilesDispersion ( true ) ; $ result = $ uploader -> save ( $ this -> mediaDirectory -> getAbsolutePath ( $ baseTmpPath ) ) ; if ( ! $ result ) { throw new LocalizedException ( __ ( 'File can not be saved to the destination folder.' ) ) ; } /**
         * Workaround for prototype 1.7 methods "isJSON", "evalJSON" on Windows OS
         */ $ result [ 'tmp_name' ] = str_replace ( '\\' , '/' , $ result [ 'tmp_name' ] ) ; $ result [ 'path' ] = str_replace ( '\\' , '/' , $ result [ 'path' ] ) ; $ result [ 'url' ] = $ this -> getBaseUrl ( ) . $ this -> getFilePath ( $ baseTmpPath , $ result [ 'file' ] ) ; if ( isset ( $ result [ 'file' ] ) ) { try { $ relativePath = rtrim ( $ baseTmpPath , '/' ) . '/' . ltrim ( $ result [ 'file' ] , '/' ) ; $ this -> coreFileStorageDatabase -> saveFile ( $ relativePath ) ; } catch ( \ Exception $ e ) { $ this -> logger -> critical ( $ e ) ; throw new LocalizedException ( __ ( 'Something went wrong while saving the file(s).' ) ) ; } } return $ result ; }
Checking file for save and save it to tmp dir

@param string $fileId

@return string[]

@throws \Magento\Framework\Exception\LocalizedException
Checking file for save and save it to tmp dir