Files
wticreatorstudio/Modules/StudioPlus/Services/ImportService.php
T
2024-02-12 22:54:20 -05:00

35 lines
928 B
PHP

<?php
namespace Modules\StudioPlus\Services;
use Illuminate\Support\Facades\Storage;
use Maatwebsite\Excel\Facades\Excel;
use Modules\StudioPlus\Imports\StudioPlusVideoImport;
use Illuminate\Support\Str;
class ImportService
{
public function handleUpload($file)
{
$filename = $file->getClientOriginalName();
$temp_path = $this->getTempLocalStoragePath();
Storage::put("$temp_path/path.dat", $temp_path);
$temp_filename = Str::random() . $filename;
Storage::putFileAs($temp_path, $file, $temp_filename);
return "$temp_path/$temp_filename";
}
public function importVideos($path)
{
ini_set('memory_limit', '6000M');
Excel::import(new StudioPlusVideoImport, $path);
Storage::delete($path);
}
public function getTempLocalStoragePath()
{
return "CreatorStudio/temp/import";
}
}