mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-18 05:25:40 +09:00
fix(media): stream large files and honour size settings (#3387)
This commit is contained in:
1 parent
6acd7f3d22
commit
45b78a13c2
97 files changed
+2547
-409
No files matched your search
@@ -1,9 +1,15 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import {AVATAR_MAX_SIZE, EMOJI_MAX_SIZE, STICKER_MAX_SIZE} from '@fluxer/constants/src/LimitConstants';
|
||||
import {
|
||||
AVATAR_MAX_SIZE,
|
||||
BASE64_IMAGE_MAX_SIZE,
|
||||
EMOJI_MAX_SIZE,
|
||||
STICKER_MAX_SIZE,
|
||||
} from '@fluxer/constants/src/LimitConstants';
|
||||
import {ValidationErrorCodes} from '@fluxer/constants/src/ValidationErrorCodes';
|
||||
import {
|
||||
base64LengthForBytes,
|
||||
createBase64ImageType,
|
||||
createBase64StringType,
|
||||
FilenameType,
|
||||
isValidBase64,
|
||||
@@ -120,6 +126,7 @@ describe('base64LengthForBytes', () => {
|
||||
[4, 8],
|
||||
[EMOJI_MAX_SIZE, 699052],
|
||||
[AVATAR_MAX_SIZE, 13981016],
|
||||
[BASE64_IMAGE_MAX_SIZE, 139810136],
|
||||
])('encodes a ceiling of %i bytes in %i characters', (bytes, expected) => {
|
||||
expect(base64LengthForBytes(bytes)).toBe(expected);
|
||||
});
|
||||
@@ -138,3 +145,13 @@ describe('base64LengthForBytes', () => {
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
describe('createBase64ImageType', () => {
|
||||
it.each([EMOJI_MAX_SIZE + 1, STICKER_MAX_SIZE * 2, AVATAR_MAX_SIZE + 1])(
|
||||
'accepts %i decoded bytes so configured size limits above the stock values can apply',
|
||||
(bytes) => {
|
||||
const encoded = Buffer.alloc(bytes, 1).toString('base64');
|
||||
expect(createBase64ImageType().parse(encoded)).toBe(encoded);
|
||||
},
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user