mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-05-14 17:25:01 +00:00
Merge remote-tracking branch 'origin/master' into light
# Conflicts: # .env.testing # README.md # composer.json # composer.lock # config/language-translations.php # config/vuefilemanager.php # public/chunks/admin.js # public/chunks/database.js # public/chunks/demo.js # public/chunks/files.js # public/chunks/my-shared-items.js # public/chunks/platform.js # public/chunks/recent-uploads.js # public/chunks/settings-storage.js # public/chunks/settings.js # public/chunks/shared.js # public/chunks/shared/browser.js # public/chunks/shared/single-file.js # public/chunks/sign-in.js # public/chunks/status-check.js # public/chunks/trash.js # public/chunks/user-storage.js # public/css/tailwind.css # public/js/main.js # public/mix-manifest.json # resources/js/components/Subscription/UserFixedSubscriptionDetail.vue # resources/js/store/modules/userAuth.js # resources/js/views/Admin.vue # resources/js/views/Admin/PaymentSettings/PaymentSettingsTab/Payments.vue # resources/js/views/Admin/Plans.vue # resources/js/views/Admin/Plans/Create/CreateFixedPlan.vue # resources/js/views/Admin/Settings/AppSettingsTabs/SignInUp.vue # resources/js/views/Demo.vue # resources/js/views/Frontpage/Homepage.vue # resources/js/views/Platform.vue # resources/views/index.blade.php # src/App/Console/Commands/SetupWebsocketEnvironment.php # src/App/Users/Models/UserLimitation.php # src/Domain/RemoteUpload/Controllers/RemoteUploadFileController.php # src/Domain/RemoteUpload/Controllers/UploadFilesRemotelyForUploadRequestController.php # src/Domain/RemoteUpload/Controllers/VisitorRemoteUploadFileController.php # src/Domain/RemoteUpload/Requests/RemoteUploadRequest.php # src/Domain/Settings/Controllers/StoreBroadcastServiceCredentialsController.php # src/Domain/Settings/Controllers/StorePaymentServiceCredentialsController.php # src/Domain/SetupWizard/Controllers/StoreEnvironmentSettingsController.php # src/Domain/UploadRequest/Controllers/UploadFilesForUploadRequestController.php # src/Support/Upgrading/Controllers/UpgradingVersionsController.php
This commit is contained in:
@@ -2,11 +2,11 @@
|
||||
namespace Domain\Files\Actions;
|
||||
|
||||
use App\Users\Models\User;
|
||||
use Illuminate\Support\Str;
|
||||
use Domain\Files\Models\File;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Domain\Files\Requests\UploadRequest;
|
||||
use Domain\Traffic\Actions\RecordUploadAction;
|
||||
use League\Flysystem\UnableToRetrieveMetadata;
|
||||
|
||||
class ProcessFileAction
|
||||
{
|
||||
@@ -26,19 +26,29 @@ class ProcessFileAction
|
||||
public function __invoke(
|
||||
UploadRequest $request,
|
||||
User $user,
|
||||
string $chunkPath,
|
||||
) {
|
||||
string $name,
|
||||
): File {
|
||||
// Get local disk instance
|
||||
$localDisk = Storage::disk('local');
|
||||
|
||||
// Get file data
|
||||
$size = $localDisk->size($chunkPath);
|
||||
$mimetype = $localDisk->mimeType($chunkPath);
|
||||
$name = Str::uuid() . '.' . $request->input('extension');
|
||||
// Get file path
|
||||
$filePath = "files/$user->id/$name";
|
||||
|
||||
// Get upload limit
|
||||
// Get file size
|
||||
$size = $localDisk->size($filePath);
|
||||
|
||||
// Get upload limit size
|
||||
$uploadLimit = get_settings('upload_limit');
|
||||
|
||||
// Get mimetype
|
||||
try {
|
||||
$fileType = getFileType(
|
||||
$localDisk->mimeType($filePath)
|
||||
);
|
||||
} catch (UnableToRetrieveMetadata $e) {
|
||||
$fileType = 'file';
|
||||
}
|
||||
|
||||
// File size handling
|
||||
if ($uploadLimit && $size > format_bytes($uploadLimit)) {
|
||||
abort(413);
|
||||
@@ -47,26 +57,24 @@ class ProcessFileAction
|
||||
// Check if user has enough space to upload file
|
||||
if (! $user->canUpload($size)) {
|
||||
// Delete file from chunk directory
|
||||
$localDisk->delete($chunkPath);
|
||||
|
||||
// Set up response
|
||||
$response = response([
|
||||
'type' => 'error',
|
||||
'message' => __t('user_action_not_allowed'),
|
||||
], 401);
|
||||
$localDisk->delete($filePath);
|
||||
|
||||
// Abort code
|
||||
abort($response);
|
||||
abort(
|
||||
response([
|
||||
'type' => 'error',
|
||||
'message' => __t('user_action_not_allowed'),
|
||||
], 401)
|
||||
);
|
||||
}
|
||||
|
||||
// Move file to user directory
|
||||
$localDisk->move($chunkPath, "files/$user->id/$name");
|
||||
if ($fileType === 'image') {
|
||||
// Create multiple image thumbnails
|
||||
($this->createImageThumbnail)($name, $user->id);
|
||||
|
||||
// Create multiple image thumbnails
|
||||
($this->createImageThumbnail)($name, $user->id);
|
||||
|
||||
// Store exif data if exists
|
||||
$exif = ($this->storeExifData)("files/$user->id/$name");
|
||||
// Store exif data if exists
|
||||
$exif = ($this->storeExifData)($filePath);
|
||||
}
|
||||
|
||||
// Move file to external storage
|
||||
match (config('filesystems.default')) {
|
||||
@@ -78,7 +86,7 @@ class ProcessFileAction
|
||||
// Create new file
|
||||
$file = File::create([
|
||||
'mimetype' => $request->input('extension'),
|
||||
'type' => getFileType($mimetype),
|
||||
'type' => $fileType,
|
||||
'parent_id' => ($this->getFileParentId)($request, $user->id),
|
||||
'name' => $request->input('name'),
|
||||
'basename' => $name,
|
||||
@@ -88,7 +96,10 @@ class ProcessFileAction
|
||||
]);
|
||||
|
||||
// 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 $file;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
namespace Domain\Files\Actions;
|
||||
|
||||
use Log;
|
||||
use Str;
|
||||
use Storage;
|
||||
use Exception;
|
||||
@@ -31,7 +30,7 @@ class StoreExifDataAction
|
||||
$exif = json_decode(json_encode($exifRaw));
|
||||
|
||||
return Exif::create([
|
||||
'file_id' => Str::uuid(), // TODO: temporary store to prevent crash before app will be successfully upgraded
|
||||
'file_id' => Str::uuid(),
|
||||
'date_time_original' => $exif->DateTimeOriginal ?? null,
|
||||
'artist' => $exif->OwnerName ?? null,
|
||||
'width' => $exif->COMPUTED->Width ?? null,
|
||||
@@ -53,8 +52,6 @@ class StoreExifDataAction
|
||||
'latitude_ref' => $exif->GPSLatitudeRef ?? null,
|
||||
]);
|
||||
} catch (Exception $error) {
|
||||
Log::error('Unable to get exif data');
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
namespace Domain\Files\Controllers;
|
||||
|
||||
use Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Domain\Folders\Models\Folder;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Domain\Files\Requests\UploadRequest;
|
||||
@@ -42,8 +44,14 @@ class UploadFileController extends Controller
|
||||
->user
|
||||
: auth()->user();
|
||||
|
||||
// Get file name
|
||||
$name = Str::uuid() . '.' . $request->input('extension');
|
||||
|
||||
// Move file to user directory
|
||||
Storage::disk('local')->move($chunkPath, "files/$user->id/$name");
|
||||
|
||||
// Process file
|
||||
$file = ($this->processFie)($request, $user, $chunkPath);
|
||||
$file = ($this->processFie)($request, $user, $name);
|
||||
|
||||
return response(new FileResource($file), 201);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
namespace Domain\Files\Controllers;
|
||||
|
||||
use Str;
|
||||
use Storage;
|
||||
use Domain\Sharing\Models\Share;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Domain\Files\Requests\UploadRequest;
|
||||
@@ -53,8 +55,14 @@ class VisitorUploadFileController extends Controller
|
||||
|
||||
// Proceed after last chunk
|
||||
if ($request->boolean('is_last')) {
|
||||
// Get file name
|
||||
$name = Str::uuid() . '.' . $request->input('extension');
|
||||
|
||||
// Move file to user directory
|
||||
Storage::disk('local')->move($chunkPath, "files/{$shared->user->id}/$name");
|
||||
|
||||
// Process file
|
||||
$file = ($this->processFie)($request, $shared->user, $chunkPath);
|
||||
$file = ($this->processFie)($request, $shared->user, $name);
|
||||
|
||||
// Set public access url
|
||||
$file->setSharedPublicUrl($shared->token);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
namespace Domain\Localization\Actions;
|
||||
|
||||
use DB;
|
||||
use Artisan;
|
||||
|
||||
class UpdateLanguageTranslationsAction
|
||||
{
|
||||
@@ -10,9 +11,11 @@ class UpdateLanguageTranslationsAction
|
||||
collect($list)
|
||||
->each(
|
||||
fn (...$item) => DB::table('language_translations')
|
||||
->where('lang', 'en')
|
||||
->where('key', $item[1])
|
||||
->update(['value' => $item[0]])
|
||||
->where('lang', 'en')
|
||||
->where('key', $item[1])
|
||||
->update(['value' => $item[0]])
|
||||
);
|
||||
|
||||
Artisan::call('cache:clear');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
namespace Domain\Settings\Actions;
|
||||
|
||||
use ErrorException;
|
||||
use VueFileManager\Subscription\Support\EngineManager;
|
||||
use VueFileManager\Subscription\Domain\Plans\DTO\CreateFixedPlanData;
|
||||
|
||||
class TestPayPalConnectionAction
|
||||
{
|
||||
public function __construct(
|
||||
public EngineManager $subscription
|
||||
) {
|
||||
}
|
||||
|
||||
public function __invoke($credentials)
|
||||
{
|
||||
try {
|
||||
// Set temporary stripe connection
|
||||
config([
|
||||
'subscription.credentials.paypal' => [
|
||||
'secret' => $credentials['secret'],
|
||||
'id' => $credentials['key'],
|
||||
'webhook_id' => $credentials['webhook'],
|
||||
'is_live' => $credentials['live'],
|
||||
],
|
||||
]);
|
||||
|
||||
// Define test plan
|
||||
$data = CreateFixedPlanData::fromArray([
|
||||
'type' => 'fixed',
|
||||
'name' => 'Test Plan',
|
||||
'description' => null,
|
||||
'features' => [
|
||||
'max_storage_amount' => 200,
|
||||
'max_team_members' => 20,
|
||||
],
|
||||
'currency' => 'EUR',
|
||||
'amount' => 99,
|
||||
'interval' => 'month',
|
||||
]);
|
||||
|
||||
// Create test plan
|
||||
$plan = $this->subscription
|
||||
->driver('paypal')
|
||||
->createFixedPlan($data);
|
||||
|
||||
// Delete plan
|
||||
$this->subscription
|
||||
->driver('paypal')
|
||||
->deletePlan($plan['id']);
|
||||
} catch (ErrorException $error) {
|
||||
abort(
|
||||
response()->json([
|
||||
'type' => 'service-connection-error',
|
||||
'title' => 'Service Connection Error',
|
||||
'message' => $error->getMessage(),
|
||||
], 401)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
namespace Domain\Settings\Actions;
|
||||
|
||||
use ErrorException;
|
||||
use VueFileManager\Subscription\Support\EngineManager;
|
||||
use VueFileManager\Subscription\Domain\Plans\DTO\CreateFixedPlanData;
|
||||
|
||||
class TestPaystackConnectionAction
|
||||
{
|
||||
public function __construct(
|
||||
public EngineManager $subscription
|
||||
) {
|
||||
}
|
||||
|
||||
public function __invoke($credentials)
|
||||
{
|
||||
try {
|
||||
// Set temporary paystack connection
|
||||
config([
|
||||
'subscription.credentials.paystack' => [
|
||||
'secret' => $credentials['secret'],
|
||||
'public_key' => $credentials['key'],
|
||||
],
|
||||
]);
|
||||
|
||||
// Define test plan
|
||||
$data = CreateFixedPlanData::fromArray([
|
||||
'type' => 'fixed',
|
||||
'name' => 'Test Plan',
|
||||
'description' => null,
|
||||
'features' => [
|
||||
'max_storage_amount' => 200,
|
||||
'max_team_members' => 20,
|
||||
],
|
||||
'currency' => 'ZAR',
|
||||
'amount' => 99999,
|
||||
'interval' => 'month',
|
||||
]);
|
||||
|
||||
// Create test plan
|
||||
$plan = $this->subscription
|
||||
->driver('paystack')
|
||||
->createFixedPlan($data);
|
||||
|
||||
// Delete plan
|
||||
$this->subscription
|
||||
->driver('paystack')
|
||||
->deletePlan($plan['id']);
|
||||
} catch (ErrorException $error) {
|
||||
abort(
|
||||
response()->json([
|
||||
'type' => 'service-connection-error',
|
||||
'title' => 'Service Connection Error',
|
||||
'message' => $error->getMessage(),
|
||||
], 401)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
namespace Domain\Settings\Actions;
|
||||
|
||||
use ErrorException;
|
||||
use VueFileManager\Subscription\Support\EngineManager;
|
||||
use VueFileManager\Subscription\Domain\Plans\DTO\CreateFixedPlanData;
|
||||
|
||||
class TestStripeConnectionAction
|
||||
{
|
||||
public function __construct(
|
||||
public EngineManager $subscription
|
||||
) {
|
||||
}
|
||||
|
||||
public function __invoke($credentials)
|
||||
{
|
||||
try {
|
||||
// Set temporary stripe connection
|
||||
config([
|
||||
'subscription.credentials.stripe' => [
|
||||
'secret' => $credentials['secret'],
|
||||
'public_key' => $credentials['key'],
|
||||
'webhook_key' => $credentials['webhook'],
|
||||
],
|
||||
]);
|
||||
|
||||
// Define test plan
|
||||
$data = CreateFixedPlanData::fromArray([
|
||||
'type' => 'fixed',
|
||||
'name' => 'Test Plan',
|
||||
'description' => null,
|
||||
'features' => [
|
||||
'max_storage_amount' => 200,
|
||||
'max_team_members' => 20,
|
||||
],
|
||||
'currency' => 'EUR',
|
||||
'amount' => 99,
|
||||
'interval' => 'month',
|
||||
]);
|
||||
|
||||
// Create test plan
|
||||
$plan = $this->subscription
|
||||
->driver('stripe')
|
||||
->createFixedPlan($data);
|
||||
|
||||
// Delete plan
|
||||
$this->subscription
|
||||
->driver('stripe')
|
||||
->deletePlan($plan['id']);
|
||||
} catch (ErrorException $error) {
|
||||
abort(
|
||||
response()->json([
|
||||
'type' => 'service-connection-error',
|
||||
'title' => 'Service Connection Error',
|
||||
'message' => $error->getMessage(),
|
||||
], 401)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -202,9 +202,9 @@ if (! function_exists('setEnvironmentValue')) {
|
||||
if ($keyPosition) {
|
||||
$endOfLinePosition = strpos($str, "\n", $keyPosition);
|
||||
$oldLine = substr($str, $keyPosition, $endOfLinePosition - $keyPosition);
|
||||
$str = str_replace($oldLine, "{$envKey}={$envValue}", $str);
|
||||
$str = str_replace($oldLine, "{$envKey}=\"{$envValue}\"", $str);
|
||||
} else {
|
||||
$str .= "\n$envKey=$envValue";
|
||||
$str .= "\n$envKey=\"$envValue\"";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user