Added ENV var to change default file upload size limit. New default value is 100MB
This commit is contained in:
parent
c04c12cf06
commit
53a1cda21c
9 changed files with 49 additions and 34 deletions
|
@ -21,6 +21,8 @@
|
|||
* Upgraded SMTP image to version 1.0.1
|
||||
* File upload route (POST /v1/storage/files) now accept a single file per request
|
||||
* Added ENV vars to change system email sender name and address
|
||||
* Usage for requests made by project admin in the console are not counted as API usage
|
||||
* Added ENV var to change default file upload size limit. New default value is 100MB
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ ENV TZ=Asia/Tel_Aviv \
|
|||
_APP_EDITION=community \
|
||||
_APP_OPTIONS_ABUSE=enabled \
|
||||
_APP_OPENSSL_KEY_V1=your-secret-key \
|
||||
_APP_STORAGE_LIMIT=104857600 \
|
||||
_APP_REDIS_HOST=redis \
|
||||
_APP_REDIS_PORT=6379 \
|
||||
_APP_DB_HOST=mariadb \
|
||||
|
@ -95,8 +96,9 @@ RUN \
|
|||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Set Upload Limit
|
||||
RUN echo "upload_max_filesize = 4M" > /etc/php/$PHP_VERSION/fpm/conf.d/appwrite.ini
|
||||
# Set Upload Limit (default to 100MB)
|
||||
RUN echo "upload_max_filesize = ${_APP_STORAGE_LIMIT}" > /etc/php/$PHP_VERSION/fpm/conf.d/appwrite.ini
|
||||
RUN echo "post_max_size = ${_APP_STORAGE_LIMIT}" > /etc/php/$PHP_VERSION/fpm/conf.d/appwrite.ini
|
||||
|
||||
# Nginx Configuration (with self-signed ssl certificates)
|
||||
COPY ./docker/nginx.conf /etc/nginx/nginx.conf
|
||||
|
|
|
@ -172,9 +172,9 @@ $utopia->get('/v1/health/stats')
|
|||
'version' => shell_exec('nginx -v 2>&1'),
|
||||
],
|
||||
'storage' => [
|
||||
'used' => $device->human($device->getDirectorySize($device->getRoot().'/')),
|
||||
'partitionTotal' => $device->human($device->getPartitionTotalSpace()),
|
||||
'partitionFree' => $device->human($device->getPartitionFreeSpace()),
|
||||
'used' => Storage::human($device->getDirectorySize($device->getRoot().'/')),
|
||||
'partitionTotal' => Storage::human($device->getPartitionTotalSpace()),
|
||||
'partitionFree' => Storage::human($device->getPartitionFreeSpace()),
|
||||
],
|
||||
'cache' => [
|
||||
'uptime' => (isset($cacheStats['uptime_in_seconds'])) ? $cacheStats['uptime_in_seconds'] : 0,
|
||||
|
|
|
@ -139,7 +139,7 @@ $utopia->post('/v1/storage/files')
|
|||
* Validators
|
||||
*/
|
||||
//$fileType = new FileType(array(FileType::FILE_TYPE_PNG, FileType::FILE_TYPE_GIF, FileType::FILE_TYPE_JPEG));
|
||||
$fileSize = new FileSize(2097152 * 2); // 4MB
|
||||
$fileSize = new FileSize($request->getServer('_APP_STORAGE_LIMIT', 0));
|
||||
$upload = new Upload();
|
||||
|
||||
if (empty($file)) {
|
||||
|
|
|
@ -7,6 +7,7 @@ global $utopia, $response, $request, $layout, $version, $providers, $projectDB;
|
|||
use Utopia\View;
|
||||
use Database\Database;
|
||||
use Database\Validator\UID;
|
||||
use Storage\Storage;
|
||||
|
||||
$utopia->init(function () use ($layout, $utopia) {
|
||||
$layout
|
||||
|
@ -205,7 +206,9 @@ $utopia->get('/console/storage')
|
|||
$page = new View(__DIR__.'/../../views/console/storage/index.phtml');
|
||||
|
||||
$page
|
||||
->setParam('home', $request->getServer('_APP_HOME', ''))
|
||||
->setParam('home', $request->getServer('_APP_HOME', 0))
|
||||
->setParam('fileLimit', $request->getServer('_APP_STORAGE_LIMIT', 0))
|
||||
->setParam('fileLimitHuman', Storage::human($request->getServer('_APP_STORAGE_LIMIT', 0)))
|
||||
;
|
||||
|
||||
$layout
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
$home = $this->getParam('home', '');
|
||||
$fileLimit = $this->getParam('fileLimit', 0);
|
||||
$fileLimitHuman = $this->getParam('fileLimitHuman', 0);
|
||||
?>
|
||||
<div class="cover margin-bottom-large">
|
||||
<h1 class="zone xl margin-bottom-large margin-top">
|
||||
|
@ -29,8 +31,10 @@ $home = $this->getParam('home', '');
|
|||
data-failure-param-alert-classname="error">
|
||||
<input type="hidden" name="folderId" id="files-folderId" data-cast-to="int" value="1">
|
||||
|
||||
<label for="file-read">Files</label>
|
||||
<input type="file" name="file" id="file-file" required>
|
||||
<label for="file-read">File</label>
|
||||
<input type="file" name="file" id="file-file" size="1" required>
|
||||
|
||||
<div class="text-fade text-size-small margin-top-negative-small margin-bottom">(Max file size allowed: <?php echo $fileLimitHuman; ?>)</div>
|
||||
|
||||
<label for="file-read">Read Permissions (<a href="<?php echo $home; ?>/docs/permissions" target="_blank">Learn more</a>)</label>
|
||||
<input type="hidden" id="file-read" name="read" required data-forms-tags data-cast-to="json" value="<?php echo htmlentities(json_encode(['*'])); ?>" />
|
||||
|
|
|
@ -16,6 +16,10 @@ Allows you to disable abuse checks and API rate limiting. By default, set to 'en
|
|||
|
||||
This is your server private secret key that is used to encrypt all sensitive data on your server. Appwrite server encrypts all secret data on your server like webhooks, HTTP passwords, user sessions, and storage files. The var is not set by default, if you wish to take advantage of Appwrite encryption capabilities you should change it and make sure to keep it a secret.
|
||||
|
||||
### _APP_STORAGE_LIMIT
|
||||
|
||||
Maximun file size allowed for file upload. The deafult value is 100MB limitation. You should pass your size limit value in bytes.
|
||||
|
||||
### _APP_CONSOLE_WHITELIST_EMAILS
|
||||
|
||||
This option is very useful for small teams or sole developers. To enable it, pass a list of allowed email addresses separated by a comma.
|
||||
|
|
|
@ -163,28 +163,4 @@ abstract class Device
|
|||
* @return float
|
||||
*/
|
||||
abstract public function getPartitionTotalSpace():float;
|
||||
|
||||
/**
|
||||
* Human readable data size format from bytes input.
|
||||
*
|
||||
* As published on https://gist.github.com/liunian/9338301 (first comment)
|
||||
*
|
||||
* @param int $bytes
|
||||
* @param int $decimals
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function human($bytes, $decimals = 2)
|
||||
{
|
||||
$units = array('B','kB','MB','GB','TB','PB','EB','ZB','YB');
|
||||
$step = 1024;
|
||||
$i = 0;
|
||||
|
||||
while (($bytes / $step) > 0.9) {
|
||||
$bytes = $bytes / $step;
|
||||
++$i;
|
||||
}
|
||||
|
||||
return round($bytes, $decimals).$units[$i];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,4 +67,28 @@ class Storage
|
|||
{
|
||||
return (bool) array_key_exists($name, self::$devices);
|
||||
}
|
||||
|
||||
/**
|
||||
* Human readable data size format from bytes input.
|
||||
*
|
||||
* As published on https://gist.github.com/liunian/9338301 (first comment)
|
||||
*
|
||||
* @param int $bytes
|
||||
* @param int $decimals
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
static public function human($bytes, $decimals = 2)
|
||||
{
|
||||
$units = array('B','kB','MB','GB','TB','PB','EB','ZB','YB');
|
||||
$step = 1024;
|
||||
$i = 0;
|
||||
|
||||
while (($bytes / $step) > 0.9) {
|
||||
$bytes = $bytes / $step;
|
||||
++$i;
|
||||
}
|
||||
|
||||
return round($bytes, $decimals).$units[$i];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue