public function copyUploadedFile(FileModelInterface $model, UploadedFile $uploadedFile, ConnectionInterface $con = null)
    {
        $newUploadedFile = null;

        if ($uploadedFile !== null) {
            $directory = $model->getUploadDir();

            $fileName = $this->renameFile($model->getId(), $uploadedFile);

            $newUploadedFile = $uploadedFile->move($directory, $fileName);
            $model->setFile($fileName);

            if (!$model->save($con)) {
                throw new ImageException(
                    sprintf(
                        'Failed to update model after copy of uploaded file %s to %s',
                        $uploadedFile,
                        $model->getFile()
                    )
                );
            }
        }

        return $newUploadedFile;
    }
public function copyUploadedFile(FileModelInterface $model, UploadedFile $uploadedFile, ConnectionInterface $con = null)
    {
        $newUploadedFile = null;

        if ($uploadedFile !== null) {
            $directory = $model->getUploadDir();

            $fileName = $this->renameFile($model->getId(), $uploadedFile);

            $newUploadedFile = $uploadedFile->move($directory, $fileName);
            $model->setFile($fileName);

            if (!$model->save($con)) {
                throw new ImageException(
                    sprintf(
                        'Failed to update model after copy of uploaded file %s to %s',
                        $uploadedFile,
                        $model->getFile()
                    )
                );
            }
        }

        return $newUploadedFile;
    }
public function copyUploadedFile ( FileModelInterface $ model , UploadedFile $ uploadedFile , ConnectionInterface $ con = null ) { $ newUploadedFile = null ; if ( $ uploadedFile !== null ) { $ directory = $ model -> getUploadDir ( ) ; $ fileName = $ this -> renameFile ( $ model -> getId ( ) , $ uploadedFile ) ; $ newUploadedFile = $ uploadedFile -> move ( $ directory , $ fileName ) ; $ model -> setFile ( $ fileName ) ; if ( ! $ model -> save ( $ con ) ) { throw new ImageException ( sprintf ( 'Failed to update model after copy of uploaded file %s to %s' , $ uploadedFile , $ model -> getFile ( ) ) ) ; } } return $ newUploadedFile ; }
Copy UploadedFile into the server storage directory

@param FileModelInterface $model        Model saved
@param UploadedFile       $uploadedFile Ready to be uploaded file
@param ConnectionInterface $con         current transaction with database

@throws \Thelia\Exception\ImageException
@return UploadedFile|null
Copy UploadedFile into the server storage directory