mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-18 08:12:15 +00:00
UnableToRetrieveMetadata error
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
APP_NAME=Laravel
|
APP_NAME=Laravel
|
||||||
APP_ENV=local
|
APP_ENV=local
|
||||||
APP_KEY=base64:V2AWruweyafrrc688xMmrsxOwwRcHeLQk3WCOTQESns=
|
APP_KEY=base64:yZKAPw49CfEkTqkD1YU25gy+RJOnns8EJ/1CaiPbDps=
|
||||||
APP_DEBUG=true
|
APP_DEBUG=true
|
||||||
APP_URL=http://localhost
|
APP_URL=http://localhost
|
||||||
APP_DEMO=false
|
APP_DEMO=false
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use Domain\Files\Models\File;
|
|||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Domain\Files\Requests\UploadRequest;
|
use Domain\Files\Requests\UploadRequest;
|
||||||
use Domain\Traffic\Actions\RecordUploadAction;
|
use Domain\Traffic\Actions\RecordUploadAction;
|
||||||
|
use League\Flysystem\UnableToRetrieveMetadata;
|
||||||
|
|
||||||
class ProcessFileAction
|
class ProcessFileAction
|
||||||
{
|
{
|
||||||
@@ -26,18 +27,28 @@ class ProcessFileAction
|
|||||||
UploadRequest $request,
|
UploadRequest $request,
|
||||||
User $user,
|
User $user,
|
||||||
string $name,
|
string $name,
|
||||||
) {
|
): File {
|
||||||
// Get local disk instance
|
// Get local disk instance
|
||||||
$localDisk = Storage::disk('local');
|
$localDisk = Storage::disk('local');
|
||||||
|
|
||||||
|
// Get file path
|
||||||
$filePath = "files/$user->id/$name";
|
$filePath = "files/$user->id/$name";
|
||||||
|
|
||||||
// Get file data
|
// Get file size
|
||||||
$size = $localDisk->size($filePath);
|
$size = $localDisk->size($filePath);
|
||||||
$mimetype = $localDisk->mimeType($filePath);
|
|
||||||
|
|
||||||
// Get upload limit
|
// Get upload limit size
|
||||||
$uploadLimit = get_settings('upload_limit');
|
$uploadLimit = get_settings('upload_limit');
|
||||||
|
|
||||||
|
// Get mimetype
|
||||||
|
try {
|
||||||
|
$fileType = getFileType(
|
||||||
|
$localDisk->mimeType($filePath)
|
||||||
|
);
|
||||||
|
} catch (UnableToRetrieveMetadata $e) {
|
||||||
|
$fileType = 'file';
|
||||||
|
}
|
||||||
|
|
||||||
// File size handling
|
// File size handling
|
||||||
if ($uploadLimit && $size > format_bytes($uploadLimit)) {
|
if ($uploadLimit && $size > format_bytes($uploadLimit)) {
|
||||||
abort(413);
|
abort(413);
|
||||||
@@ -57,11 +68,13 @@ class ProcessFileAction
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create multiple image thumbnails
|
if ($fileType === 'image') {
|
||||||
($this->createImageThumbnail)($name, $user->id);
|
// Create multiple image thumbnails
|
||||||
|
($this->createImageThumbnail)($name, $user->id);
|
||||||
|
|
||||||
// Store exif data if exists
|
// Store exif data if exists
|
||||||
$exif = ($this->storeExifData)($filePath);
|
$exif = ($this->storeExifData)($filePath);
|
||||||
|
}
|
||||||
|
|
||||||
// Move file to external storage
|
// Move file to external storage
|
||||||
match (config('filesystems.default')) {
|
match (config('filesystems.default')) {
|
||||||
@@ -73,7 +86,7 @@ class ProcessFileAction
|
|||||||
// Create new file
|
// Create new file
|
||||||
$file = File::create([
|
$file = File::create([
|
||||||
'mimetype' => $request->input('extension'),
|
'mimetype' => $request->input('extension'),
|
||||||
'type' => getFileType($mimetype),
|
'type' => $fileType,
|
||||||
'parent_id' => ($this->getFileParentId)($request, $user->id),
|
'parent_id' => ($this->getFileParentId)($request, $user->id),
|
||||||
'name' => $request->input('name'),
|
'name' => $request->input('name'),
|
||||||
'basename' => $name,
|
'basename' => $name,
|
||||||
@@ -83,7 +96,10 @@ class ProcessFileAction
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
// Attach file into the exif data
|
// Attach file into the exif data
|
||||||
$exif?->update(['file_id' => $file->id]);
|
|
||||||
|
if ($fileType === 'image') {
|
||||||
|
$exif?->update(['file_id' => $file->id]);
|
||||||
|
}
|
||||||
|
|
||||||
// Return new file
|
// Return new file
|
||||||
return $file;
|
return $file;
|
||||||
|
|||||||
Reference in New Issue
Block a user