Fix File Upload (#952)

* Log correct file name

* Remove duplicated throws comment

* Set maxSize

* Add hints

* Fix unit conversion

* Add translations
This commit is contained in:
MartinOscar 2025-02-14 11:11:52 +01:00 committed by GitHub
parent 09375df8a7
commit b355830db4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 11 additions and 3 deletions

View File

@ -224,6 +224,9 @@ class CreateNode extends CreateRecord
->columnSpan(2), ->columnSpan(2),
TextInput::make('upload_size') TextInput::make('upload_size')
->label(trans('admin/node.upload_limit')) ->label(trans('admin/node.upload_limit'))
->helperText(trans('admin/node.upload_limit_help.0'))
->hintIcon('tabler-question-mark')
->hintIconTooltip(trans('admin/node.upload_limit_help.1'))
->columnSpan(1) ->columnSpan(1)
->numeric()->required() ->numeric()->required()
->default(256) ->default(256)

View File

@ -271,6 +271,8 @@ class EditNode extends EditRecord
'lg' => 1, 'lg' => 1,
]) ])
->label(trans('admin/node.upload_limit')) ->label(trans('admin/node.upload_limit'))
->hintIcon('tabler-question-mark')
->hintIconTooltip(trans('admin/node.upload_limit_help.0') . trans('admin/node.upload_limit_help.1'))
->numeric()->required() ->numeric()->required()
->minValue(1) ->minValue(1)
->maxValue(1024) ->maxValue(1024)

View File

@ -474,7 +474,7 @@ class ListFiles extends ListRecords
Activity::event('server:file.uploaded') Activity::event('server:file.uploaded')
->property('directory', $this->path) ->property('directory', $this->path)
->property('file', $file->getFilename()) ->property('file', $file->getClientOriginalName())
->log(); ->log();
} }
} elseif ($data['url'] !== null) { } elseif ($data['url'] !== null) {
@ -498,10 +498,10 @@ class ListFiles extends ListRecords
->live() ->live()
->schema([ ->schema([
FileUpload::make('files') FileUpload::make('files')
->label('File(s)')
->storeFiles(false) ->storeFiles(false)
->previewable(false) ->previewable(false)
->preserveFilenames() ->preserveFilenames()
->maxSize((int) round($server->node->upload_size * (config('panel.use_binary_prefix') ? 1.048576 * 1024 : 1000)))
->multiple(), ->multiple(),
]), ]),
Tab::make('Upload From URL') Tab::make('Upload From URL')

View File

@ -14,7 +14,6 @@ class DaemonFileRepository extends DaemonRepository
* *
* @param int|null $notLargerThan the maximum content length in bytes * @param int|null $notLargerThan the maximum content length in bytes
* *
* @throws ConnectionException
* @throws FileSizeTooLargeException * @throws FileSizeTooLargeException
* @throws ConnectionException * @throws ConnectionException
* @throws FileNotFoundException * @throws FileNotFoundException

View File

@ -52,6 +52,10 @@ return [
'tags' => 'Tags', 'tags' => 'Tags',
'upload_limit' => 'Upload Limit', 'upload_limit' => 'Upload Limit',
'upload_limit_help' => [
'Enter the maximum size of files that can be uploaded through the web-based file manager.',
'Make sure your webserver supports file uploads of this size!',
],
'sftp_port' => 'SFTP Port', 'sftp_port' => 'SFTP Port',
'sftp_alias' => 'SFTP Alias', 'sftp_alias' => 'SFTP Alias',
'sftp_alias_help' => 'Display alias for the SFTP address. Leave empty to use the Node FQDN.', 'sftp_alias_help' => 'Display alias for the SFTP address. Leave empty to use the Node FQDN.',