use configurable file size for drag and drop too (#846)

pull/848/head
Thomas Michelat 2024-04-11 18:06:57 +02:00 committed by GitHub
parent 8617aa5e3e
commit c75598cc80
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 5 additions and 6 deletions

View File

@ -1,8 +1,8 @@
import { readSetting } from "$sb/lib/settings_page.ts";
import { editor, space } from "$sb/syscalls.ts";
import { UploadFile } from "../../plug-api/types.ts";
import { maximumAttachmentSize } from "../../web/constants.ts";
const maximumAttachmentSize = 10; // MiB
function folderName(path: string) {
return path.split("/").slice(0, -1).join("/");

View File

@ -195,11 +195,10 @@ export function attachmentExtension(editor: Client) {
suggestedName: string,
mimeType: string,
) {
if (data!.byteLength > maximumAttachmentSize) {
const maxSize = editor.settings.maximumAttachmentSize || maximumAttachmentSize;
if (data!.byteLength > (maxSize * 1024 * 1024)) {
editor.flashNotification(
`Attachment is too large, maximum is ${
maximumAttachmentSize / 1024 / 1024
}MB`,
`Attachment is too large, maximum is ${maxSize}MiB`,
"error",
);
return;

View File

@ -1 +1 @@
export const maximumAttachmentSize = 1024 * 1024 * 10; // 10MB
export const maximumAttachmentSize = 10; // MiB