Merge pull request #2655 from aynsix/PHRAS-2119-tmp_files-during-upload

PHRAS-2119 use tmp_files on upload file
This commit is contained in:
Nicolas Maillat
2018-06-29 03:59:38 +00:00
committed by GitHub

View File

@@ -128,7 +128,20 @@ class UploadController extends Controller
try {
// Add file extension, so mediavorus can guess file type for octet-stream file
$uploadedFilename = $file->getRealPath();
$renamedFilename = $file->getRealPath() . '.' . pathinfo($file->getClientOriginalName(), PATHINFO_EXTENSION);
$renamedFilename = null;
if(!empty($this->app['conf']->get(['main', 'storage', 'tmp_files']))){
$tmpStorage = \p4string::addEndSlash($this->app['conf']->get(['main', 'storage', 'tmp_files'])).'upload/';
if(!is_dir($tmpStorage)){
$this->getFilesystem()->mkdir($tmpStorage);
}
$renamedFilename = $tmpStorage. pathinfo($file->getRealPath(), PATHINFO_FILENAME) .'.' . pathinfo($file->getClientOriginalName(), PATHINFO_EXTENSION);
}else{
$renamedFilename = $file->getRealPath() . '.' . pathinfo($file->getClientOriginalName(), PATHINFO_EXTENSION);
}
$this->getFilesystem()->rename($uploadedFilename, $renamedFilename);