Fixed presentation slides upload issue
Change-Id: I554e103d574c3f79911dd30abc28330eacd82775
This commit is contained in:
parent
8bd1d7e3e6
commit
d65b404d60
@ -53,17 +53,28 @@ final class FileUploader implements IFileUploader
|
||||
$attachment = new File();
|
||||
try {
|
||||
|
||||
$local_path = Storage::putFileAs(sprintf('/public/%s', $folder_name), $file, $file->getClientOriginalName());
|
||||
$client_original_name = $file->getClientOriginalName();
|
||||
Log::debug(sprintf("FileUploader::build: folder_name %s client original name %s", $folder_name, $client_original_name));
|
||||
|
||||
$local_path = Storage::putFileAs(sprintf('/public/%s', $folder_name), $file, $client_original_name);
|
||||
|
||||
Log::debug(sprintf("FileUploader::build: saved to local path %s", $local_path));
|
||||
|
||||
Log::debug(sprintf("FileUploader::build: invoking folder service findOrMake folder_name %s", $folder_name));
|
||||
$folder = $this->folder_service->findOrMake($folder_name);
|
||||
$local_path = Storage::disk()->path($local_path);
|
||||
$attachment->setParent($folder);
|
||||
$attachment->setName($file->getClientOriginalName());
|
||||
$attachment->setFilename(sprintf("assets/%s/%s", $folder_name, $file->getClientOriginalName()));
|
||||
$attachment->setTitle(str_replace(array('-', '_'), ' ', preg_replace('/\.[^.]+$/', '', $file->getClientOriginalName())));
|
||||
$attachment->setName($client_original_name);
|
||||
$file_name = sprintf("assets/%s/%s", $folder_name, $client_original_name);
|
||||
Log::debug(sprintf("FileUploader::build file_name %s", $file_name));
|
||||
$title = str_replace(array('-', '_'), ' ', preg_replace('/\.[^.]+$/', '', $file->getClientOriginalName()));
|
||||
$attachment->setFilename($file_name);
|
||||
Log::debug(sprintf("FileUploader::build title %s", $title));
|
||||
$attachment->setTitle($title);
|
||||
$attachment->setShowInSearch(true);
|
||||
if ($is_image) // set className
|
||||
$attachment->setImage();
|
||||
|
||||
Log::debug(sprintf("FileUploader::build uploading to bucket %s", $local_path));
|
||||
$this->bucket->put($attachment, $local_path);
|
||||
$attachment->setCloudMeta('LastPut', time());
|
||||
$attachment->setCloudStatus('Live');
|
||||
|
@ -11,6 +11,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use libs\utils\ITransactionService;
|
||||
use models\main\File;
|
||||
use models\main\IFolderRepository;
|
||||
@ -46,7 +48,7 @@ final class FolderService
|
||||
public function findOrMake($folder_name)
|
||||
{
|
||||
return $this->tx_service->transaction(function() use($folder_name){
|
||||
|
||||
Log::debug(sprintf("FolderService::findOrMake folder_name %s", $folder_name));
|
||||
$folder = $this->folder_repository->getFolderByFileName($folder_name);
|
||||
if(!is_null($folder)) return $folder;
|
||||
|
||||
@ -57,10 +59,12 @@ final class FolderService
|
||||
$item = null;
|
||||
$file_name = null;
|
||||
foreach($parts as $part) {
|
||||
Log::debug(sprintf("FolderService::findOrMake part %s", $part));
|
||||
if(!$part) continue; // happens for paths with a trailing slash
|
||||
if(!empty($file_name))
|
||||
$file_name .= '/';
|
||||
$file_name .= $part;
|
||||
Log::debug(sprintf("FolderService::findOrMake file_name %s", $file_name));
|
||||
$item = is_null($parent) ?
|
||||
$this->folder_repository->getFolderByName($part) :
|
||||
$this->folder_repository->getFolderByNameAndParent($part, $parent);
|
||||
|
@ -714,7 +714,7 @@ final class PresentationService
|
||||
|
||||
$slideFile = $this->file_uploader->build(
|
||||
$file,
|
||||
sprintf('summits/%s/presentations/%s/slides/', $presentation->getSummitId(), $presentation_id),
|
||||
sprintf('summits/%s/presentations/%s/slides', $presentation->getSummitId(), $presentation_id),
|
||||
false);
|
||||
$slide->setSlide($slideFile);
|
||||
}
|
||||
@ -806,7 +806,7 @@ final class PresentationService
|
||||
throw new ValidationException(sprintf("file exceeds max_file_size (%s MB).", ($max_file_size / 1024) / 1024));
|
||||
}
|
||||
|
||||
$slideFile = $this->file_uploader->build($file, sprintf('summits/%s/presentations/%s/slides/', $presentation->getSummitId(), $presentation_id), false);
|
||||
$slideFile = $this->file_uploader->build($file, sprintf('summits/%s/presentations/%s/slides', $presentation->getSummitId(), $presentation_id), false);
|
||||
$slide->setSlide($slideFile);
|
||||
$slide->clearLink();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user