- S3 storages compatibility with v2
- user profile fixes
@@ -11,6 +11,7 @@ use App\Models\Setting;
|
|||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Faker;
|
use Faker;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class SetupDevEnvironment extends Command
|
class SetupDevEnvironment extends Command
|
||||||
@@ -114,7 +115,7 @@ class SetupDevEnvironment extends Command
|
|||||||
'timezone' => $this->faker->randomElement(['+1.0', '+2.0', '+3.0']),
|
'timezone' => $this->faker->randomElement(['+1.0', '+2.0', '+3.0']),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
\File::copy(storage_path("demo/avatars/avatar-01.png"), storage_path("app/avatars/avatar-01.png"));
|
Storage::putFileAs("avatars", storage_path("demo/avatars/avatar-01.png"), 'avatar-01.png', "private");
|
||||||
|
|
||||||
// Show user credentials
|
// Show user credentials
|
||||||
$this->info('Default admin account created. Email: howdy@hi5ve.digital and Password: vuefilemanager');
|
$this->info('Default admin account created. Email: howdy@hi5ve.digital and Password: vuefilemanager');
|
||||||
@@ -155,7 +156,7 @@ class SetupDevEnvironment extends Command
|
|||||||
'timezone' => $this->faker->randomElement(['+1.0', '+2.0', '+3.0']),
|
'timezone' => $this->faker->randomElement(['+1.0', '+2.0', '+3.0']),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
\File::copy(storage_path("demo/avatars/{$user['avatar']}"), storage_path("app/avatars/{$user['avatar']}"));
|
Storage::putFileAs("avatars", storage_path("demo/avatars/{$user['avatar']}"), $user['avatar'], "private");
|
||||||
|
|
||||||
$this->info("Generated user with email: $newbie->email and Password: vuefilemanager");
|
$this->info("Generated user with email: $newbie->email and Password: vuefilemanager");
|
||||||
});
|
});
|
||||||
@@ -378,7 +379,7 @@ class SetupDevEnvironment extends Command
|
|||||||
$basename = Str::random(12) . '-' . $file['basename'];
|
$basename = Str::random(12) . '-' . $file['basename'];
|
||||||
|
|
||||||
// Copy file into app storage
|
// Copy file into app storage
|
||||||
\File::copy(storage_path("demo/documents/{$file['basename']}"), storage_path("app/files/$user->id/$basename"));
|
Storage::putFileAs("files/$user->id", storage_path("demo/documents/{$file['basename']}"), $basename, "private");
|
||||||
|
|
||||||
// Create file record
|
// Create file record
|
||||||
File::create([
|
File::create([
|
||||||
@@ -422,7 +423,7 @@ class SetupDevEnvironment extends Command
|
|||||||
$basename = Str::random(12) . '-' . $file['basename'];
|
$basename = Str::random(12) . '-' . $file['basename'];
|
||||||
|
|
||||||
// Copy file into app storage
|
// Copy file into app storage
|
||||||
\File::copy(storage_path("demo/documents/{$file['basename']}"), storage_path("app/files/$user->id/$basename"));
|
Storage::putFileAs("files/$user->id", storage_path("demo/documents/{$file['basename']}"), $basename, "private");
|
||||||
|
|
||||||
// Create file record
|
// Create file record
|
||||||
File::create([
|
File::create([
|
||||||
@@ -456,7 +457,7 @@ class SetupDevEnvironment extends Command
|
|||||||
$basename = Str::random(12) . '-' . $file['basename'];
|
$basename = Str::random(12) . '-' . $file['basename'];
|
||||||
|
|
||||||
// Copy file into app storage
|
// Copy file into app storage
|
||||||
\File::copy(storage_path("demo/documents/{$file['basename']}"), storage_path("app/files/$user->id/$basename"));
|
Storage::putFileAs("files/$user->id", storage_path("demo/documents/{$file['basename']}"), $basename, "private");
|
||||||
|
|
||||||
// Create file record
|
// Create file record
|
||||||
File::create([
|
File::create([
|
||||||
@@ -515,7 +516,7 @@ class SetupDevEnvironment extends Command
|
|||||||
$basename = Str::random(12) . '-' . $file['basename'];
|
$basename = Str::random(12) . '-' . $file['basename'];
|
||||||
|
|
||||||
// Copy file into app storage
|
// Copy file into app storage
|
||||||
\File::copy(storage_path("demo/documents/{$file['basename']}"), storage_path("app/files/$user->id/$basename"));
|
Storage::putFileAs("files/$user->id", storage_path("demo/documents/{$file['basename']}"), $basename, "private");
|
||||||
|
|
||||||
// Create file record
|
// Create file record
|
||||||
File::create([
|
File::create([
|
||||||
@@ -543,7 +544,7 @@ class SetupDevEnvironment extends Command
|
|||||||
$basename = Str::random(12) . '-' . $file;
|
$basename = Str::random(12) . '-' . $file;
|
||||||
|
|
||||||
// Copy file into app storage
|
// Copy file into app storage
|
||||||
\File::copy(storage_path("demo/video/$file"), storage_path("app/files/$user->id/$basename"));
|
Storage::putFileAs("files/$user->id", storage_path("demo/video/$file"), $basename, "private");
|
||||||
|
|
||||||
// Create file record
|
// Create file record
|
||||||
File::create([
|
File::create([
|
||||||
@@ -568,7 +569,7 @@ class SetupDevEnvironment extends Command
|
|||||||
$basename = Str::random(12) . '-' . $file;
|
$basename = Str::random(12) . '-' . $file;
|
||||||
|
|
||||||
// Copy file into app storage
|
// Copy file into app storage
|
||||||
\File::copy(storage_path("demo/video/$file"), storage_path("app/files/$user->id/$basename"));
|
Storage::putFileAs("files/$user->id", storage_path("demo/video/$file"), $basename, "private");
|
||||||
|
|
||||||
// Create file record
|
// Create file record
|
||||||
File::create([
|
File::create([
|
||||||
@@ -593,7 +594,7 @@ class SetupDevEnvironment extends Command
|
|||||||
$basename = Str::random(12) . '-' . $file;
|
$basename = Str::random(12) . '-' . $file;
|
||||||
|
|
||||||
// Copy file into app storage
|
// Copy file into app storage
|
||||||
\File::copy(storage_path("demo/audio/$file"), storage_path("app/files/$user->id/$basename"));
|
Storage::putFileAs("files/$user->id", storage_path("demo/audio/$file"), $basename, "private");
|
||||||
|
|
||||||
// Create file record
|
// Create file record
|
||||||
File::create([
|
File::create([
|
||||||
@@ -629,9 +630,8 @@ class SetupDevEnvironment extends Command
|
|||||||
$basename = Str::random(12) . '-' . $file;
|
$basename = Str::random(12) . '-' . $file;
|
||||||
|
|
||||||
// Copy file into app storage
|
// Copy file into app storage
|
||||||
\File::copy(storage_path("demo/images/memes/$file"), storage_path("app/files/$user->id/$basename"));
|
Storage::putFileAs("files/$user->id", storage_path("demo/images/memes/$file"), $basename, "private");
|
||||||
|
Storage::putFileAs("files/$user->id", storage_path("demo/images/memes/thumbnail-$file"), "thumbnail-$basename", "private");
|
||||||
$this->info("Creating thumbnail for image: $file");
|
|
||||||
|
|
||||||
// Create file record
|
// Create file record
|
||||||
File::create([
|
File::create([
|
||||||
@@ -643,7 +643,7 @@ class SetupDevEnvironment extends Command
|
|||||||
'author' => 'user',
|
'author' => 'user',
|
||||||
'mimetype' => 'jpg',
|
'mimetype' => 'jpg',
|
||||||
'filesize' => rand(1000000, 4000000),
|
'filesize' => rand(1000000, 4000000),
|
||||||
'thumbnail' => $this->helper->create_image_thumbnail("files/$user->id/$basename", $file, $user->id),
|
'thumbnail' => "thumbnail-$basename",
|
||||||
'created_at' => now()->subMinutes(rand(1, 5)),
|
'created_at' => now()->subMinutes(rand(1, 5)),
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
@@ -663,9 +663,8 @@ class SetupDevEnvironment extends Command
|
|||||||
$basename = Str::random(12) . '-' . $file;
|
$basename = Str::random(12) . '-' . $file;
|
||||||
|
|
||||||
// Copy file into app storage
|
// Copy file into app storage
|
||||||
\File::copy(storage_path("demo/images/apartments/$file"), storage_path("app/files/$user->id/$basename"));
|
Storage::putFileAs("files/$user->id", storage_path("demo/images/apartments/$file"), $basename, "private");
|
||||||
|
Storage::putFileAs("files/$user->id", storage_path("demo/images/apartments/thumbnail-$file"), "thumbnail-$basename", "private");
|
||||||
$this->info("Creating thumbnail for image: $file");
|
|
||||||
|
|
||||||
// Create file record
|
// Create file record
|
||||||
File::create([
|
File::create([
|
||||||
@@ -677,7 +676,7 @@ class SetupDevEnvironment extends Command
|
|||||||
'author' => 'user',
|
'author' => 'user',
|
||||||
'mimetype' => 'jpg',
|
'mimetype' => 'jpg',
|
||||||
'filesize' => rand(1000000, 4000000),
|
'filesize' => rand(1000000, 4000000),
|
||||||
'thumbnail' => $this->helper->create_image_thumbnail("files/$user->id/$basename", $file, $user->id),
|
'thumbnail' => "thumbnail-$basename",
|
||||||
'created_at' => now()->subMinutes(rand(1, 5)),
|
'created_at' => now()->subMinutes(rand(1, 5)),
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
@@ -701,9 +700,8 @@ class SetupDevEnvironment extends Command
|
|||||||
$basename = Str::random(12) . '-' . $file;
|
$basename = Str::random(12) . '-' . $file;
|
||||||
|
|
||||||
// Copy file into app storage
|
// Copy file into app storage
|
||||||
\File::copy(storage_path("demo/images/nature/$file"), storage_path("app/files/$user->id/$basename"));
|
Storage::putFileAs("files/$user->id", storage_path("demo/images/nature/$file"), $basename, "private");
|
||||||
|
Storage::putFileAs("files/$user->id", storage_path("demo/images/nature/thumbnail-$file"), "thumbnail-$basename", "private");
|
||||||
$this->info("Creating thumbnail for image: $file");
|
|
||||||
|
|
||||||
// Create file record
|
// Create file record
|
||||||
File::create([
|
File::create([
|
||||||
@@ -715,7 +713,7 @@ class SetupDevEnvironment extends Command
|
|||||||
'author' => 'user',
|
'author' => 'user',
|
||||||
'mimetype' => 'jpg',
|
'mimetype' => 'jpg',
|
||||||
'filesize' => rand(1000000, 4000000),
|
'filesize' => rand(1000000, 4000000),
|
||||||
'thumbnail' => $this->helper->create_image_thumbnail("files/$user->id/$basename", $file, $user->id),
|
'thumbnail' => "thumbnail-$basename",
|
||||||
'created_at' => now()->subMinutes(rand(1, 5)),
|
'created_at' => now()->subMinutes(rand(1, 5)),
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
@@ -878,7 +876,7 @@ class SetupDevEnvironment extends Command
|
|||||||
// Get system images
|
// Get system images
|
||||||
collect(['logo.svg', 'logo-horizontal.svg', 'favicon.png', 'og-image.jpg', 'touch-icon.png'])
|
collect(['logo.svg', 'logo-horizontal.svg', 'favicon.png', 'og-image.jpg', 'touch-icon.png'])
|
||||||
->each(function ($file) {
|
->each(function ($file) {
|
||||||
\File::copy(storage_path("demo/app/$file"), storage_path("app/system/$file"));
|
Storage::putFileAs("system", storage_path("demo/app/$file"), $file, "private");
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,16 +43,19 @@ class BrowseShareController extends Controller
|
|||||||
$image = File::whereUserId($shared->user_id)
|
$image = File::whereUserId($shared->user_id)
|
||||||
->whereType('image')
|
->whereType('image')
|
||||||
->whereId($shared->item_id)
|
->whereId($shared->item_id)
|
||||||
->firstOrFail();
|
->first();
|
||||||
|
|
||||||
// Store user download size
|
if ($image) {
|
||||||
$shared
|
|
||||||
->user
|
|
||||||
->record_download(
|
|
||||||
(int)$image->getRawOriginal('filesize')
|
|
||||||
);
|
|
||||||
|
|
||||||
return $this->get_single_image($image, $shared->user_id);
|
// Store user download size
|
||||||
|
$shared
|
||||||
|
->user
|
||||||
|
->record_download(
|
||||||
|
(int)$image->getRawOriginal('filesize')
|
||||||
|
);
|
||||||
|
|
||||||
|
return $this->get_single_image($image, $shared->user_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return view("index")
|
return view("index")
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ class File extends Model
|
|||||||
// Get thumbnail from external storage
|
// Get thumbnail from external storage
|
||||||
if ($this->attributes['thumbnail'] && ! is_storage_driver(['local'])) {
|
if ($this->attributes['thumbnail'] && ! is_storage_driver(['local'])) {
|
||||||
|
|
||||||
return Storage::temporaryUrl('files/' . $this->attributes['thumbnail'], now()->addHour());
|
return Storage::temporaryUrl("files/$this->user_id/{$this->attributes['thumbnail']}", now()->addHour());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get thumbnail from local storage
|
// Get thumbnail from local storage
|
||||||
@@ -145,7 +145,7 @@ class File extends Model
|
|||||||
'ResponseContentDisposition' => 'attachment; filename=' . $file_pretty_name,
|
'ResponseContentDisposition' => 'attachment; filename=' . $file_pretty_name,
|
||||||
];
|
];
|
||||||
|
|
||||||
return Storage::temporaryUrl('files/' . $this->attributes['basename'], now()->addDay(), $header);
|
return Storage::temporaryUrl("files/$this->user_id/{$this->attributes['basename']}", now()->addDay(), $header);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get thumbnail from local storage
|
// Get thumbnail from local storage
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class UserSettings extends Model
|
|||||||
public function getAvatarAttribute()
|
public function getAvatarAttribute()
|
||||||
{
|
{
|
||||||
// Get avatar from external storage
|
// Get avatar from external storage
|
||||||
if ($this->attributes['avatar'] && is_storage_driver(['s3', 'spaces', 'wasabi', 'backblaze'])) {
|
if ($this->attributes['avatar'] && ! is_storage_driver('local')) {
|
||||||
return Storage::temporaryUrl($this->attributes['avatar'], now()->addDay());
|
return Storage::temporaryUrl($this->attributes['avatar'], now()->addDay());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,6 +31,6 @@ class UserSettings extends Model
|
|||||||
return url('/' . $this->attributes['avatar']);
|
return url('/' . $this->attributes['avatar']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return url('/assets/images/' . 'default-avatar.png');
|
return url('/assets/images/default-avatar.png');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,13 +52,14 @@ class FileManagerService
|
|||||||
|
|
||||||
// Move file to local storage from external storage service
|
// Move file to local storage from external storage service
|
||||||
if (!is_storage_driver('local')) {
|
if (!is_storage_driver('local')) {
|
||||||
$files->each(function ($file) use ($disk_local) {
|
|
||||||
|
foreach ($files as $file) {
|
||||||
try {
|
try {
|
||||||
$disk_local->put("temp/$file->basename", Storage::get("files/$file->user_id/$file->basename"));
|
$disk_local->put("temp/{$file['basename']}", Storage::get("files/$requested_folder->user_id/{$file['basename']}"));
|
||||||
} catch (FileNotFoundException $e) {
|
} catch (FileNotFoundException $e) {
|
||||||
throw new HttpException(404, 'File not found');
|
throw new HttpException(404, 'File not found');
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get zip path
|
// Get zip path
|
||||||
@@ -67,17 +68,16 @@ class FileManagerService
|
|||||||
// Create zip
|
// Create zip
|
||||||
$zip = Madzipper::make($disk_local->path("zip/$zip_name"));
|
$zip = Madzipper::make($disk_local->path("zip/$zip_name"));
|
||||||
|
|
||||||
// Get files folder on local storage drive
|
|
||||||
$directory = is_storage_driver('local') ? 'files' : 'temp';
|
|
||||||
|
|
||||||
// Add files to zip
|
// Add files to zip
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
|
|
||||||
|
$file_path = is_storage_driver('local')
|
||||||
|
? $disk_local->path("files/$requested_folder->user_id/{$file['basename']}")
|
||||||
|
: $disk_local->path("temp/{$file['basename']}");
|
||||||
|
|
||||||
$zip
|
$zip
|
||||||
->folder($file['folder_path'])
|
->folder($file['folder_path'])
|
||||||
->addString(
|
->addString("{$file['name']}.{$file['mimetype']}", File::get($file_path));
|
||||||
"{$file['name']}.{$file['mimetype']}",
|
|
||||||
File::get($disk_local->path("/$directory/$requested_folder->user_id/{$file['basename']}"))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close zip
|
// Close zip
|
||||||
@@ -114,6 +114,7 @@ class FileManagerService
|
|||||||
|
|
||||||
// Move file to local storage from external storage service
|
// Move file to local storage from external storage service
|
||||||
if (!is_storage_driver('local')) {
|
if (!is_storage_driver('local')) {
|
||||||
|
|
||||||
$files->each(function ($file) use ($disk_local) {
|
$files->each(function ($file) use ($disk_local) {
|
||||||
try {
|
try {
|
||||||
$disk_local->put("temp/$file->basename", Storage::get("files/$file->user_id/$file->basename"));
|
$disk_local->put("temp/$file->basename", Storage::get("files/$file->user_id/$file->basename"));
|
||||||
@@ -129,14 +130,14 @@ class FileManagerService
|
|||||||
// Create zip
|
// Create zip
|
||||||
$zip = Madzipper::make($disk_local->path("zip/$zip_name"));
|
$zip = Madzipper::make($disk_local->path("zip/$zip_name"));
|
||||||
|
|
||||||
// Get files folder on local storage drive
|
|
||||||
$directory = is_storage_driver('local') ? 'files' : 'temp';
|
|
||||||
|
|
||||||
// Add files to zip
|
// Add files to zip
|
||||||
$files->each(function ($file) use ($zip, $directory, $disk_local) {
|
$files->each(function ($file) use ($zip, $disk_local) {
|
||||||
$zip->addString(
|
|
||||||
"$file->name.$file->mimetype",
|
$file_path = is_storage_driver('local')
|
||||||
File::get($disk_local->path("/$directory/$file->user_id/$file->basename")));
|
? $disk_local->path("files/$file->user_id/$file->basename")
|
||||||
|
: $disk_local->path("temp/$file->basename");
|
||||||
|
|
||||||
|
$zip->addString("$file->name.$file->mimetype", File::get($file_path));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Close zip
|
// Close zip
|
||||||
@@ -388,27 +389,25 @@ class FileManagerService
|
|||||||
$disk_local = Storage::disk('local');
|
$disk_local = Storage::disk('local');
|
||||||
|
|
||||||
// Get user data
|
// Get user data
|
||||||
$user_id = $shared ? $shared->user_id : Auth::id();
|
$user_id = $shared->user_id ?? Auth::id();
|
||||||
|
|
||||||
// File Info
|
// File Info
|
||||||
$file_size = $disk_local->size('chunks/' . $temp_filename);
|
$file_size = $disk_local->size("chunks/$temp_filename");
|
||||||
|
|
||||||
$file_mimetype = $disk_local->mimeType('chunks/' . $temp_filename);
|
$file_mimetype = $disk_local->mimeType("chunks/$temp_filename");
|
||||||
|
|
||||||
// Check if user has enough space to upload file
|
// Check if user has enough space to upload file
|
||||||
$this->helper->check_user_storage_capacity($user_id, $file_size, $temp_filename);
|
$this->helper->check_user_storage_capacity($user_id, $file_size, $temp_filename);
|
||||||
|
|
||||||
// Create thumbnail
|
// Create thumbnail
|
||||||
$thumbnail = $this->helper->create_image_thumbnail('chunks/' . $temp_filename, $disk_file_name, $user_id);
|
$thumbnail = $this->helper->create_image_thumbnail("chunks/$temp_filename", $disk_file_name, $user_id);
|
||||||
|
|
||||||
// Move finished file from chunk to file-manager directory
|
// Move finished file from chunk to file-manager directory
|
||||||
$disk_local->move('chunks/' . $temp_filename, "files/$user_id/$disk_file_name");
|
$disk_local->move("chunks/$temp_filename", "files/$user_id/$disk_file_name");
|
||||||
|
|
||||||
// Move files to external storage
|
// Move files to external storage
|
||||||
if (!is_storage_driver(['local'])) {
|
if (!is_storage_driver(['local'])) {
|
||||||
|
$this->helper->move_file_to_external_storage($disk_file_name, $user_id);
|
||||||
// Move file to external storage service
|
|
||||||
$this->helper->move_file_to_external_storage($disk_file_name, $thumbnail);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store user upload size
|
// Store user upload size
|
||||||
|
|||||||
@@ -120,66 +120,60 @@ class HelperService
|
|||||||
/**
|
/**
|
||||||
* Move file to external storage if is set
|
* Move file to external storage if is set
|
||||||
*
|
*
|
||||||
* @param string $filename
|
* @param string $file
|
||||||
* @param string|null $thumbnail
|
* @param string $user_id
|
||||||
*/
|
*/
|
||||||
function move_file_to_external_storage($filename, $thumbnail = null): void
|
function move_file_to_external_storage($file, $user_id): void
|
||||||
{
|
{
|
||||||
$disk_local = Storage::disk('local');
|
$disk_local = Storage::disk('local');
|
||||||
|
|
||||||
foreach ([$filename, $thumbnail] as $file) {
|
// Get file size
|
||||||
|
$filesize = $disk_local->size("files/$user_id/$file");
|
||||||
|
|
||||||
// Check if file exist
|
// If file is bigger than 5.2MB then run multipart upload
|
||||||
if (!$file) continue;
|
if ($filesize > 5242880) {
|
||||||
|
|
||||||
// Get file size
|
// Get driver
|
||||||
$filesize = $disk_local->size('files/' . $file);
|
$driver = \Storage::getDriver();
|
||||||
|
|
||||||
// If file is bigger than 5.2MB then run multipart upload
|
// Get adapter
|
||||||
if ($filesize > 5242880) {
|
$adapter = $driver->getAdapter();
|
||||||
|
|
||||||
// Get driver
|
// Get client
|
||||||
$driver = \Storage::getDriver();
|
$client = $adapter->getClient();
|
||||||
|
|
||||||
// Get adapter
|
// Prepare the upload parameters.
|
||||||
$adapter = $driver->getAdapter();
|
// TODO: replace local files with temp folder
|
||||||
|
$uploader = new MultipartUploader($client, config('filesystems.disks.local.root') . "/files/$user_id/$file", [
|
||||||
|
'bucket' => $adapter->getBucket(),
|
||||||
|
'key' => "/files/$user_id/$file"
|
||||||
|
]);
|
||||||
|
|
||||||
// Get client
|
try {
|
||||||
$client = $adapter->getClient();
|
|
||||||
|
|
||||||
// Prepare the upload parameters.
|
// Upload content
|
||||||
// TODO: replace local files with temp folder
|
$uploader->upload();
|
||||||
$uploader = new MultipartUploader($client, config('filesystems.disks.local.root') . '/files/' . $file, [
|
|
||||||
'bucket' => $adapter->getBucket(),
|
|
||||||
'key' => 'files/' . $file
|
|
||||||
]);
|
|
||||||
|
|
||||||
try {
|
} catch (MultipartUploadException $e) {
|
||||||
|
|
||||||
// Upload content
|
// Write error log
|
||||||
$uploader->upload();
|
Log::error($e->getMessage());
|
||||||
|
|
||||||
} catch (MultipartUploadException $e) {
|
// Delete file after error
|
||||||
|
$disk_local->delete("/files/$user_id/$file");
|
||||||
|
|
||||||
// Write error log
|
throw new HttpException(409, $e->getMessage());
|
||||||
Log::error($e->getMessage());
|
|
||||||
|
|
||||||
// Delete file after error
|
|
||||||
$disk_local->delete('files/' . $file);
|
|
||||||
|
|
||||||
throw new HttpException(409, $e->getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
// Stream file object to s3
|
|
||||||
// TODO: replace local files with temp folder
|
|
||||||
Storage::putFileAs('files', config('filesystems.disks.local.root') . '/files/' . $file, $file, 'private');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete file after upload
|
} else {
|
||||||
$disk_local->delete('files/' . $file);
|
|
||||||
|
// Stream file object to s3
|
||||||
|
// TODO: replace local files with temp folder
|
||||||
|
Storage::putFileAs("files/$user_id", config('filesystems.disks.local.root') . "/files/$user_id/$file", $file, "private");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete file after upload
|
||||||
|
$disk_local->delete("/files/$user_id/$file");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -192,16 +186,14 @@ class HelperService
|
|||||||
*/
|
*/
|
||||||
function create_image_thumbnail($file_path, $filename, $user_id)
|
function create_image_thumbnail($file_path, $filename, $user_id)
|
||||||
{
|
{
|
||||||
$local_disk = Storage::disk('local');
|
|
||||||
|
|
||||||
// Create thumbnail from image
|
// Create thumbnail from image
|
||||||
if (in_array($local_disk->mimeType($file_path), ['image/gif', 'image/jpeg', 'image/jpg', 'image/png', 'image/webp'])) {
|
if (in_array(Storage::disk('local')->mimeType($file_path), ['image/gif', 'image/jpeg', 'image/jpg', 'image/png', 'image/webp'])) {
|
||||||
|
|
||||||
// Get thumbnail name
|
// Get thumbnail name
|
||||||
$thumbnail = "thumbnail-$filename";
|
$thumbnail = "thumbnail-$filename";
|
||||||
|
|
||||||
// Create intervention image
|
// Create intervention image
|
||||||
$image = Image::make($local_disk->path($file_path))
|
$image = Image::make(Storage::disk('local')->path($file_path))
|
||||||
->orientate();
|
->orientate();
|
||||||
|
|
||||||
// Resize image
|
// Resize image
|
||||||
@@ -210,11 +202,11 @@ class HelperService
|
|||||||
})->stream();
|
})->stream();
|
||||||
|
|
||||||
// Store thumbnail to disk
|
// Store thumbnail to disk
|
||||||
$local_disk->put("files/$user_id/$thumbnail", $image);
|
Storage::put("files/$user_id/$thumbnail", $image);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return thumbnail as svg file
|
// Return thumbnail as svg file
|
||||||
if ($local_disk->mimeType($file_path) === 'image/svg+xml') {
|
if (Storage::disk('local')->mimeType($file_path) === 'image/svg+xml') {
|
||||||
|
|
||||||
$thumbnail = $filename;
|
$thumbnail = $filename;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,8 +12,8 @@
|
|||||||
"brianium/paratest": "^6.2",
|
"brianium/paratest": "^6.2",
|
||||||
"cartalyst/stripe-laravel": "^13.1",
|
"cartalyst/stripe-laravel": "^13.1",
|
||||||
"doctrine/dbal": "^2.12.1",
|
"doctrine/dbal": "^2.12.1",
|
||||||
"fideloper/proxy": "^4.0",
|
"fideloper/proxy": "^4.4.1",
|
||||||
"fruitcake/laravel-cors": "^2.0",
|
"fruitcake/laravel-cors": "^2.0.3",
|
||||||
"gabrielelana/byte-units": "^0.5.0",
|
"gabrielelana/byte-units": "^0.5.0",
|
||||||
"guzzlehttp/guzzle": "^7.2.0",
|
"guzzlehttp/guzzle": "^7.2.0",
|
||||||
"intervention/image": "^2.5.1",
|
"intervention/image": "^2.5.1",
|
||||||
@@ -21,25 +21,25 @@
|
|||||||
"kyslik/column-sortable": "^6.4",
|
"kyslik/column-sortable": "^6.4",
|
||||||
"laravel/cashier": "^12.9.1",
|
"laravel/cashier": "^12.9.1",
|
||||||
"laravel/fortify": "^1.7.7",
|
"laravel/fortify": "^1.7.7",
|
||||||
"laravel/framework": "^8.26.1",
|
"laravel/framework": "^8.30.1",
|
||||||
"laravel/sanctum": "^2.9",
|
"laravel/sanctum": "^2.9",
|
||||||
"laravel/tinker": "^2.0",
|
"laravel/tinker": "^2.6.1",
|
||||||
"laravel/ui": "^3.0",
|
"laravel/ui": "^3.2.0",
|
||||||
"league/flysystem-aws-s3-v3": "^1.0",
|
"league/flysystem-aws-s3-v3": "^1.0.29",
|
||||||
"league/flysystem-cached-adapter": "^1.0",
|
"league/flysystem-cached-adapter": "^1.1.0",
|
||||||
"madnest/madzipper": "^1.1",
|
"madnest/madzipper": "^1.1.0",
|
||||||
"teamtnt/laravel-scout-tntsearch-driver": "^11.1",
|
"teamtnt/laravel-scout-tntsearch-driver": "^11.1.0",
|
||||||
"ext-json": "*"
|
"ext-json": "*"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"barryvdh/laravel-ide-helper": "^2.7",
|
"barryvdh/laravel-ide-helper": "^2.9",
|
||||||
"facade/ignition": "^2.3.6",
|
"facade/ignition": "^2.5.14",
|
||||||
"fzaninotto/faker": "^1.9.1",
|
"fzaninotto/faker": "^1.9.2",
|
||||||
"mockery/mockery": "^1.3.1",
|
"mockery/mockery": "^1.4.3",
|
||||||
"nunomaduro/collision": "^5.0",
|
"nunomaduro/collision": "^5.3.0",
|
||||||
"phpunit/phpunit": "^9.5.2",
|
"phpunit/phpunit": "^9.5.2",
|
||||||
"supliu/laravel-query-monitor": "^1.0"
|
"supliu/laravel-query-monitor": "^1.0.2"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"optimize-autoloader": true,
|
"optimize-autoloader": true,
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
"/chunks/app-billings.js": "/chunks/app-billings.js?id=82133cc16f55222bbbe6",
|
"/chunks/app-billings.js": "/chunks/app-billings.js?id=82133cc16f55222bbbe6",
|
||||||
"/chunks/app-email.js": "/chunks/app-email.js?id=c578a85112c6a4b1ed0e",
|
"/chunks/app-email.js": "/chunks/app-email.js?id=c578a85112c6a4b1ed0e",
|
||||||
"/chunks/app-index.js": "/chunks/app-index.js?id=7f07dceace5c9c8255bb",
|
"/chunks/app-index.js": "/chunks/app-index.js?id=7f07dceace5c9c8255bb",
|
||||||
"/chunks/app-language.js": "/chunks/app-language.js?id=e97b8b4e0a0f5ac93c97",
|
"/chunks/app-language.js": "/chunks/app-language.js?id=7d53dfb62599e204babb",
|
||||||
"/chunks/app-language~chunks/dashboard~chunks/files~chunks/invoices~chunks/pages~chunks/plans~chunks/s~38c276fc.js": "/chunks/app-language~chunks/dashboard~chunks/files~chunks/invoices~chunks/pages~chunks/plans~chunks/s~38c276fc.js?id=e4abf38870f961cb6979",
|
"/chunks/app-language~chunks/dashboard~chunks/files~chunks/invoices~chunks/pages~chunks/plans~chunks/s~38c276fc.js": "/chunks/app-language~chunks/dashboard~chunks/files~chunks/invoices~chunks/pages~chunks/plans~chunks/s~38c276fc.js?id=e4abf38870f961cb6979",
|
||||||
"/chunks/app-others.js": "/chunks/app-others.js?id=9156adba3b1697a8bf3e",
|
"/chunks/app-others.js": "/chunks/app-others.js?id=9156adba3b1697a8bf3e",
|
||||||
"/chunks/app-payments.js": "/chunks/app-payments.js?id=7e1a982c90174f568fb2",
|
"/chunks/app-payments.js": "/chunks/app-payments.js?id=7e1a982c90174f568fb2",
|
||||||
@@ -55,13 +55,13 @@
|
|||||||
"/chunks/plans.js": "/chunks/plans.js?id=608bdbd5c041b728691a",
|
"/chunks/plans.js": "/chunks/plans.js?id=608bdbd5c041b728691a",
|
||||||
"/chunks/platform.js": "/chunks/platform.js?id=559a62d18ff169793e54",
|
"/chunks/platform.js": "/chunks/platform.js?id=559a62d18ff169793e54",
|
||||||
"/chunks/platform~chunks/shared.js": "/chunks/platform~chunks/shared.js?id=3d5804463c897995e9d1",
|
"/chunks/platform~chunks/shared.js": "/chunks/platform~chunks/shared.js?id=3d5804463c897995e9d1",
|
||||||
"/chunks/profile.js": "/chunks/profile.js?id=fb4a46afdd09cdcdc7da",
|
"/chunks/profile.js": "/chunks/profile.js?id=1c1c666004fb44b1c404",
|
||||||
"/chunks/profile~chunks/settings-password.js": "/chunks/profile~chunks/settings-password.js?id=d448806bfefc6cc43f0d",
|
"/chunks/profile~chunks/settings-password.js": "/chunks/profile~chunks/settings-password.js?id=d448806bfefc6cc43f0d",
|
||||||
"/chunks/purchase-code.js": "/chunks/purchase-code.js?id=e00ee12cde704060e15b",
|
"/chunks/purchase-code.js": "/chunks/purchase-code.js?id=e00ee12cde704060e15b",
|
||||||
"/chunks/settings.js": "/chunks/settings.js?id=2637c005a9c8b01cfc9b",
|
"/chunks/settings.js": "/chunks/settings.js?id=ef7888a7d65d159a15e0",
|
||||||
"/chunks/settings-create-payment-methods.js": "/chunks/settings-create-payment-methods.js?id=88849e6ddce9226d49a5",
|
"/chunks/settings-create-payment-methods.js": "/chunks/settings-create-payment-methods.js?id=88849e6ddce9226d49a5",
|
||||||
"/chunks/settings-invoices.js": "/chunks/settings-invoices.js?id=444b9bbc310647ddd297",
|
"/chunks/settings-invoices.js": "/chunks/settings-invoices.js?id=444b9bbc310647ddd297",
|
||||||
"/chunks/settings-password.js": "/chunks/settings-password.js?id=d24053a92c2594439d04",
|
"/chunks/settings-password.js": "/chunks/settings-password.js?id=46961d5c0fc91f4ad638",
|
||||||
"/chunks/settings-payment-methods.js": "/chunks/settings-payment-methods.js?id=3bc709a228c0849a6f62",
|
"/chunks/settings-payment-methods.js": "/chunks/settings-payment-methods.js?id=3bc709a228c0849a6f62",
|
||||||
"/chunks/settings-storage.js": "/chunks/settings-storage.js?id=ced13fc6a34233fb53aa",
|
"/chunks/settings-storage.js": "/chunks/settings-storage.js?id=ced13fc6a34233fb53aa",
|
||||||
"/chunks/settings-subscription.js": "/chunks/settings-subscription.js?id=22e5c49d5b0a154e1a28",
|
"/chunks/settings-subscription.js": "/chunks/settings-subscription.js?id=22e5c49d5b0a154e1a28",
|
||||||
@@ -90,5 +90,8 @@
|
|||||||
"/chunks/users.js": "/chunks/users.js?id=f1057be5cf73ebc32c14",
|
"/chunks/users.js": "/chunks/users.js?id=f1057be5cf73ebc32c14",
|
||||||
"/vendors~chunks/admin~chunks/admin-account~chunks/app-appearance~chunks/app-billings~chunks/app-email~0d496e20.js": "/vendors~chunks/admin~chunks/admin-account~chunks/app-appearance~chunks/app-billings~chunks/app-email~0d496e20.js?id=a9facd8e57a0dd054f8c",
|
"/vendors~chunks/admin~chunks/admin-account~chunks/app-appearance~chunks/app-billings~chunks/app-email~0d496e20.js": "/vendors~chunks/admin~chunks/admin-account~chunks/app-appearance~chunks/app-billings~chunks/app-email~0d496e20.js?id=a9facd8e57a0dd054f8c",
|
||||||
"/vendors~chunks/admin~chunks/admin-account~chunks/app-appearance~chunks/app-billings~chunks/app-email~7afe9e20.js": "/vendors~chunks/admin~chunks/admin-account~chunks/app-appearance~chunks/app-billings~chunks/app-email~7afe9e20.js?id=6d6e7e4191c9e2705c8a",
|
"/vendors~chunks/admin~chunks/admin-account~chunks/app-appearance~chunks/app-billings~chunks/app-email~7afe9e20.js": "/vendors~chunks/admin~chunks/admin-account~chunks/app-appearance~chunks/app-billings~chunks/app-email~7afe9e20.js?id=6d6e7e4191c9e2705c8a",
|
||||||
"/vendors~chunks/files~chunks/platform~chunks/shared~chunks/shared-files~chunks/shared/file-browser~ch~52c14f2e.js": "/vendors~chunks/files~chunks/platform~chunks/shared~chunks/shared-files~chunks/shared/file-browser~ch~52c14f2e.js?id=66afa0e341251a68c3d3"
|
"/vendors~chunks/files~chunks/platform~chunks/shared~chunks/shared-files~chunks/shared/file-browser~ch~52c14f2e.js": "/vendors~chunks/files~chunks/platform~chunks/shared~chunks/shared-files~chunks/shared/file-browser~ch~52c14f2e.js?id=66afa0e341251a68c3d3",
|
||||||
|
"/chunks/settings.0962f7b2c8b3d7976177.hot-update.js": "/chunks/settings.0962f7b2c8b3d7976177.hot-update.js",
|
||||||
|
"/chunks/settings-password.0962f7b2c8b3d7976177.hot-update.js": "/chunks/settings-password.0962f7b2c8b3d7976177.hot-update.js",
|
||||||
|
"/chunks/profile.dc4bd2e371de2e1cd237.hot-update.js": "/chunks/profile.dc4bd2e371de2e1cd237.hot-update.js"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@
|
|||||||
reader.readAsDataURL(file)
|
reader.readAsDataURL(file)
|
||||||
|
|
||||||
// Update user avatar
|
// Update user avatar
|
||||||
this.$updateImage('/user/profile', 'avatar', event.target.files[0])
|
this.$updateImage('/user/relationships/settings', 'avatar', event.target.files[0])
|
||||||
} else {
|
} else {
|
||||||
alert( this.$t('validation_errors.wrong_image') )
|
alert( this.$t('validation_errors.wrong_image') )
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -178,7 +178,7 @@
|
|||||||
methods: {
|
methods: {
|
||||||
changeUserName() {
|
changeUserName() {
|
||||||
this.$store.commit('UPDATE_NAME', this.userInfo.name)
|
this.$store.commit('UPDATE_NAME', this.userInfo.name)
|
||||||
this.$updateText('/user/profile', 'name', this.userInfo.name)
|
this.$updateText('/user/relationships/settings', 'name', this.userInfo.name)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
|||||||
|
After Width: | Height: | Size: 57 KiB |
BIN
storage/demo/images/apartments/thumbnail-Apartment Chair.jpg
Normal file
|
After Width: | Height: | Size: 42 KiB |
|
After Width: | Height: | Size: 95 KiB |
|
After Width: | Height: | Size: 87 KiB |
BIN
storage/demo/images/apartments/thumbnail-Home.jpg
Normal file
|
After Width: | Height: | Size: 100 KiB |
BIN
storage/demo/images/apartments/thumbnail-Kitchen Appliances.jpg
Normal file
|
After Width: | Height: | Size: 56 KiB |
BIN
storage/demo/images/apartments/thumbnail-Kitchen Island.jpg
Normal file
|
After Width: | Height: | Size: 85 KiB |
BIN
storage/demo/images/memes/thumbnail-Eggcited bro.jpg
Normal file
|
After Width: | Height: | Size: 62 KiB |
BIN
storage/demo/images/memes/thumbnail-Get Your Shit Together.jpg
Normal file
|
After Width: | Height: | Size: 31 KiB |
BIN
storage/demo/images/memes/thumbnail-Get a Rest.jpg
Normal file
|
After Width: | Height: | Size: 46 KiB |
|
After Width: | Height: | Size: 39 KiB |
BIN
storage/demo/images/memes/thumbnail-Have a Nice Day.jpg
Normal file
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 26 KiB |
BIN
storage/demo/images/memes/thumbnail-It Works On My Machine.jpg
Normal file
|
After Width: | Height: | Size: 35 KiB |
|
After Width: | Height: | Size: 46 KiB |
BIN
storage/demo/images/memes/thumbnail-Sofishticated.jpg
Normal file
|
After Width: | Height: | Size: 37 KiB |
BIN
storage/demo/images/memes/thumbnail-You Are My Sunshine.jpg
Normal file
|
After Width: | Height: | Size: 72 KiB |
BIN
storage/demo/images/memes/thumbnail-whaaaaat.jpg
Normal file
|
After Width: | Height: | Size: 33 KiB |
|
After Width: | Height: | Size: 227 KiB |
BIN
storage/demo/images/nature/thumbnail-Close Up Of Peacock.jpg
Normal file
|
After Width: | Height: | Size: 48 KiB |
|
After Width: | Height: | Size: 98 KiB |
BIN
storage/demo/images/nature/thumbnail-Cold Nature Cute Ice.jpg
Normal file
|
After Width: | Height: | Size: 84 KiB |
|
After Width: | Height: | Size: 79 KiB |
|
After Width: | Height: | Size: 52 KiB |
|
After Width: | Height: | Size: 149 KiB |
|
After Width: | Height: | Size: 80 KiB |
BIN
storage/demo/images/nature/thumbnail-Waterfall Between Trees.jpg
Normal file
|
After Width: | Height: | Size: 238 KiB |
|
After Width: | Height: | Size: 83 KiB |
BIN
storage/demo/images/nature/thumbnail-Yellow Animal Eyes Fur.jpg
Normal file
|
After Width: | Height: | Size: 237 KiB |