Skip to content

Commit

Permalink
NEW Allow changing parallelUploads config in UploadField (#1539)
Browse files Browse the repository at this point in the history
NEW Allow changing parallelUploads config in UploadField
  • Loading branch information
mikaldl authored Feb 11, 2025
1 parent e57ed00 commit 0ef0b17
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion client/dist/js/bundle.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions client/src/components/UploadField/UploadField.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ class UploadField extends Component {
url: this.props.data.createFileEndpoint.url,
method: this.props.data.createFileEndpoint.method,
paramName: 'Upload',
parallelUploads: this.props.data.maxParallelUploads,
maxFiles,
maxFilesize,
thumbnailWidth: CONSTANTS.SMALL_THUMBNAIL_WIDTH,
Expand Down
23 changes: 23 additions & 0 deletions code/Forms/UploadField.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ class UploadField extends FormField implements FileHandleField
*/
protected $allowedMaxFileNumber = null;

/**
* Set the max amount of parallel uploads
*/
protected int $maxParallelUploads = 2;

protected $inputType = 'file';

protected $schemaDataType = FormField::SCHEMA_DATA_TYPE_CUSTOM;
Expand Down Expand Up @@ -116,6 +121,7 @@ public function getSchemaDataDefaults()

$defaults['data']['maxFilesize'] = $this->getAllowedMaxFileSize() / 1024 / 1024;
$defaults['data']['maxFiles'] = $this->getAllowedMaxFileNumber();
$defaults['data']['maxParallelUploads'] = $this->getMaxParallelUploads();
$defaults['data']['multi'] = $this->getIsMultiUpload();
$defaults['data']['parentid'] = $this->getFolderID();
$defaults['data']['canUpload'] = $this->getUploadEnabled();
Expand Down Expand Up @@ -366,6 +372,23 @@ public function setUploadEnabled($uploadEnabled)
return $this;
}

/**
* Get the amount of max parallel uploads
*/
public function getMaxParallelUploads(): int
{
return $this->maxParallelUploads;
}

/**
* Set amount of max parallel uploads
*/
public function setMaxParallelUploads(int $maxParallelUploads): static
{
$this->maxParallelUploads = $maxParallelUploads;
return $this;
}

/**
* Check if attaching files is enabled
*
Expand Down
1 change: 1 addition & 0 deletions tests/php/Forms/UploadFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public function testGetAttributes()
'maxFiles' => null,
'canUpload' => true,
'canAttach' => true,
'maxParallelUploads' => 2
],
'schemaType' => 'Custom'
];
Expand Down

0 comments on commit 0ef0b17

Please sign in to comment.