Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/app_local.example.php
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,7 @@
// ],
// 'uploadMaxResolution' => '1920x1080',
// 'uploadMaxSize' => -1, // -1 means no limit, otherwise set a limit in bytes
// 'uploadTimeout' => 30000, // in milliseconds

/**
* Configuration for "Children" association parameters.
Expand Down
2 changes: 1 addition & 1 deletion resources/js/app/mixins/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const FetchMixin = {
createCustomAxios() {
return axios.create({
baseURL: BEDITA.base,
timeout: 30000,
timeout: BEDITA?.uploadConfig?.timeout || 30000,
credentials: 'same-origin',
headers: {
'accept': 'application/json',
Expand Down
18 changes: 17 additions & 1 deletion src/View/Helper/SystemHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,20 @@ class SystemHelper extends Helper
],
];

/**
* Maximum size for uploaded files, in bytes
*
* @var int
*/
protected int $defaultUploadMaxSize = -1;

/**
* Timeout for upload operations, in milliseconds
*
* @var int
*/
protected int $defaultUploadTimeout = 30000; // in milliseconds

/**
* Maximum resolution for images
*
Expand Down Expand Up @@ -166,8 +180,10 @@ public function uploadConfig(): array
$accepted = (array)Configure::read('uploadAccepted', $this->defaultUploadAccepted);
$forbidden = (array)Configure::read('uploadForbidden', $this->defaultUploadForbidden);
$maxResolution = (string)Configure::read('uploadMaxResolution', $this->defaultUploadMaxResolution);
$maxSize = (int)Configure::read('uploadMaxSize', $this->defaultUploadMaxSize);
$timeout = (int)Configure::read('uploadTimeout', $this->defaultUploadTimeout);

return compact('accepted', 'forbidden', 'maxResolution');
return compact('accepted', 'forbidden', 'maxResolution', 'maxSize', 'timeout');
}

/**
Expand Down
8 changes: 7 additions & 1 deletion tests/TestCase/View/Helper/SystemHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,13 @@ public function testUploadConfig(): void
$property = $reflectionClass->getProperty('defaultUploadMaxResolution');
$property->setAccessible(true);
$maxResolution = $property->getValue($this->System);
$expected = compact('accepted', 'forbidden', 'maxResolution');
$property = $reflectionClass->getProperty('defaultUploadMaxSize');
$property->setAccessible(true);
$maxSize = $property->getValue($this->System);
$property = $reflectionClass->getProperty('defaultUploadTimeout');
$property->setAccessible(true);
$timeout = $property->getValue($this->System);
$expected = compact('accepted', 'forbidden', 'maxResolution', 'maxSize', 'timeout');
$actual = $this->System->uploadConfig();
static::assertSame($expected, $actual);
}
Expand Down
Loading