feat: adding file management
This commit is contained in:
parent
4f80673a96
commit
880a997828
7 changed files with 315 additions and 0 deletions
87
app/Http/Controllers/FileController.php
Normal file
87
app/Http/Controllers/FileController.php
Normal file
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Helpers\LengthFormatter;
|
||||
use App\Jobs\FileJob;
|
||||
use App\Models\File;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class FileController extends Controller
|
||||
{
|
||||
public function index() {
|
||||
//ToDo
|
||||
}
|
||||
|
||||
public function store(Request $request) {
|
||||
|
||||
// $user = Auth::user();
|
||||
//
|
||||
// //Accept request only from logged-in users
|
||||
// if (!$user) {
|
||||
// throw new \Exception("You must be logged in");
|
||||
// }
|
||||
|
||||
//Mime type list: https://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
|
||||
$request->validate([
|
||||
'file' => 'required|file|mimes:audio/mpeg,mpga,mp3,audio/x-wav,audio/ogg,audio/mp4',
|
||||
]);
|
||||
|
||||
$file = $request->file('file');
|
||||
$originalName = $file->getClientOriginalName();
|
||||
|
||||
$time = new LengthFormatter('00:00:00');
|
||||
|
||||
$dbFile = File::create([
|
||||
'import_status' => 1,
|
||||
'currentlyaccessing' => 0,
|
||||
'md5' => md5($request->file('file')->getRealPath()),
|
||||
'length' => $time->format(), //preparare helper che trasforma tempo in 0 years 0 mons 0 days 0 hours 0 mins 0.0 secs
|
||||
'file_exists' => true,
|
||||
'owner_id' => 1, //$user->id, //Get the user ID
|
||||
'cuein' => $time->format(), //preparare helper che trasforma tempo in 0 years 0 mons 0 days 0 hours 0 mins 0.0 secs
|
||||
'cueout' => $time->format(), //preparare helper che trasforma tempo in 0 years 0 mons 0 days 0 hours 0 mins 0.0 secs
|
||||
'silan_check' => false,
|
||||
'hidden' => true,
|
||||
'is_scheduled' => false,
|
||||
'is_playlist' => false,
|
||||
'filesize' => 0
|
||||
]);
|
||||
|
||||
$tmpFile = $file->move(Storage::disk('libretime-tmp')->path(''), $dbFile->id.'-'.$originalName);
|
||||
|
||||
//Create array to dispatch to Analyzer
|
||||
$payload = [
|
||||
'id' => $dbFile->id,
|
||||
'tmp_file_path' => $tmpFile->getPathname(),
|
||||
'import_directory' => Storage::disk('libretime-upload')->path('').'/'.'1', //$user->id,
|
||||
'original_filename' => $originalName,
|
||||
'options' => new \stdClass()
|
||||
];
|
||||
|
||||
//Queue::connection('rabbitmq')->pushRaw(json_encode($payload), 'airtime-upload');
|
||||
//Queue::dispatch(new FileJob($payload));
|
||||
}
|
||||
|
||||
public function show($id) {
|
||||
//Todo
|
||||
}
|
||||
|
||||
public function update(Request $request, $id) {
|
||||
//ToDo
|
||||
}
|
||||
|
||||
public function destroy($id) {
|
||||
//ToDo
|
||||
}
|
||||
|
||||
public function upload(Request $request) {
|
||||
|
||||
}
|
||||
|
||||
public function test() {
|
||||
return view('upload');
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue