fix: Import size should use larger of AWS_S3_UPLOAD_MAX_SIZE and MAX_IMPORT_SIZE
closes #4899
This commit is contained in:
@@ -253,15 +253,6 @@ export class Environment {
|
|||||||
process.env.ENABLE_UPDATES ?? process.env.TELEMETRY ?? "true"
|
process.env.ENABLE_UPDATES ?? process.env.TELEMETRY ?? "true"
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
|
||||||
* Because imports can be much larger than regular file attachments and are
|
|
||||||
* deleted automatically we allow an optional separate limit on the size of
|
|
||||||
* imports.
|
|
||||||
*/
|
|
||||||
@IsNumber()
|
|
||||||
public MAXIMUM_IMPORT_SIZE =
|
|
||||||
this.toOptionalNumber(process.env.MAXIMUM_IMPORT_SIZE) ?? 5120000;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An optional comma separated list of allowed domains.
|
* An optional comma separated list of allowed domains.
|
||||||
*/
|
*/
|
||||||
@@ -562,7 +553,7 @@ export class Environment {
|
|||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsNumber()
|
@IsNumber()
|
||||||
public AWS_S3_UPLOAD_MAX_SIZE =
|
public AWS_S3_UPLOAD_MAX_SIZE =
|
||||||
this.toOptionalNumber(process.env.AWS_S3_UPLOAD_MAX_SIZE) ?? 10000000000;
|
this.toOptionalNumber(process.env.AWS_S3_UPLOAD_MAX_SIZE) ?? 100000000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set default AWS S3 ACL for file attachments.
|
* Set default AWS S3 ACL for file attachments.
|
||||||
@@ -570,6 +561,17 @@ export class Environment {
|
|||||||
@IsOptional()
|
@IsOptional()
|
||||||
public AWS_S3_ACL = process.env.AWS_S3_ACL ?? "private";
|
public AWS_S3_ACL = process.env.AWS_S3_ACL ?? "private";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Because imports can be much larger than regular file attachments and are
|
||||||
|
* deleted automatically we allow an optional separate limit on the size of
|
||||||
|
* imports.
|
||||||
|
*/
|
||||||
|
@IsNumber()
|
||||||
|
public MAXIMUM_IMPORT_SIZE = Math.max(
|
||||||
|
this.toOptionalNumber(process.env.MAXIMUM_IMPORT_SIZE) ?? 100000000,
|
||||||
|
this.AWS_S3_UPLOAD_MAX_SIZE
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The product name
|
* The product name
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -65,10 +65,10 @@ export default class AttachmentHelper {
|
|||||||
*/
|
*/
|
||||||
static presetToMaxUploadSize(preset: AttachmentPreset) {
|
static presetToMaxUploadSize(preset: AttachmentPreset) {
|
||||||
switch (preset) {
|
switch (preset) {
|
||||||
case AttachmentPreset.Avatar:
|
|
||||||
return Math.min(1024 * 1024 * 5, env.AWS_S3_UPLOAD_MAX_SIZE);
|
|
||||||
case AttachmentPreset.Import:
|
case AttachmentPreset.Import:
|
||||||
return env.MAXIMUM_IMPORT_SIZE;
|
return env.MAXIMUM_IMPORT_SIZE;
|
||||||
|
case AttachmentPreset.Avatar:
|
||||||
|
case AttachmentPreset.DocumentAttachment:
|
||||||
default:
|
default:
|
||||||
return env.AWS_S3_UPLOAD_MAX_SIZE;
|
return env.AWS_S3_UPLOAD_MAX_SIZE;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user