99 lines
3 KiB
PHP
99 lines
3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Helpers\LengthFormatter;
|
|
use App\Lib\RabbitMQSender;
|
|
use App\Models\File;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Storage;
|
|
|
|
class FileController extends Controller
|
|
{
|
|
protected static $propertyDefinitions = array(
|
|
'content_type' => 'shortstr',
|
|
'content_encoding' => 'shortstr',
|
|
'application_headers' => 'table_object',
|
|
'delivery_mode' => 'octet',
|
|
'priority' => 'octet',
|
|
'correlation_id' => 'shortstr',
|
|
'reply_to' => 'shortstr',
|
|
'expiration' => 'shortstr',
|
|
'message_id' => 'shortstr',
|
|
'timestamp' => 'timestamp',
|
|
'type' => 'shortstr',
|
|
'user_id' => 'shortstr',
|
|
'app_id' => 'shortstr',
|
|
'cluster_id' => 'shortstr',
|
|
);
|
|
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,
|
|
'track_type_id' => $request->track_type_id ? $request->track_type_id : null,
|
|
]);
|
|
|
|
$tmpFile = $file->move(Storage::disk('libretime-tmp')->path(''), $dbFile->id.'-'.$originalName);
|
|
|
|
RabbitMQSender::SendMessageToAnalyzer(
|
|
$tmpFile->getPathname(),
|
|
Storage::disk('libretime-upload')->path('').'/'.'1', //$user->id,
|
|
$originalName,
|
|
$dbFile->id,
|
|
$dbFile->track_type_id
|
|
);
|
|
}
|
|
|
|
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');
|
|
}
|
|
}
|