-
-
Notifications
You must be signed in to change notification settings - Fork 184
Have More Control On Uploads
Muah edited this page Dec 25, 2017
·
18 revisions
up until now you were limited to what come pre-made with the package, but what if you wanted to do some extra operations to the uploaded file ?!! for example
re-encode a video file,
convert an audio file,
change the width & height of an image,
etc..
so to achieve that a new config key is added
'controller' => '\ctf0\MediaManager\Controllers\MediaController',
which you can use to switch the package controller to a custom one of your own, however for the most part you'll mostly be interested in the uploading process, so for that you'll need to edit the storeFile()
method ex.
<?php
namespace App\Http\Controllers;
use ctf0\MediaManager\Controllers\MediaController;
class MyAwesomeController extends MediaController
{
protected function storeFile($item, $upload_path, $file_name)
{
// do you stuff
// ...
// save the file
return $item->storeAs($upload_path, $file_name, $this->fileSystem);
}
}