use configurable file size for drag and drop too (#846)
parent
8617aa5e3e
commit
c75598cc80
|
@ -1,8 +1,8 @@
|
||||||
import { readSetting } from "$sb/lib/settings_page.ts";
|
import { readSetting } from "$sb/lib/settings_page.ts";
|
||||||
import { editor, space } from "$sb/syscalls.ts";
|
import { editor, space } from "$sb/syscalls.ts";
|
||||||
import { UploadFile } from "../../plug-api/types.ts";
|
import { UploadFile } from "../../plug-api/types.ts";
|
||||||
|
import { maximumAttachmentSize } from "../../web/constants.ts";
|
||||||
|
|
||||||
const maximumAttachmentSize = 10; // MiB
|
|
||||||
|
|
||||||
function folderName(path: string) {
|
function folderName(path: string) {
|
||||||
return path.split("/").slice(0, -1).join("/");
|
return path.split("/").slice(0, -1).join("/");
|
||||||
|
|
|
@ -195,11 +195,10 @@ export function attachmentExtension(editor: Client) {
|
||||||
suggestedName: string,
|
suggestedName: string,
|
||||||
mimeType: string,
|
mimeType: string,
|
||||||
) {
|
) {
|
||||||
if (data!.byteLength > maximumAttachmentSize) {
|
const maxSize = editor.settings.maximumAttachmentSize || maximumAttachmentSize;
|
||||||
|
if (data!.byteLength > (maxSize * 1024 * 1024)) {
|
||||||
editor.flashNotification(
|
editor.flashNotification(
|
||||||
`Attachment is too large, maximum is ${
|
`Attachment is too large, maximum is ${maxSize}MiB`,
|
||||||
maximumAttachmentSize / 1024 / 1024
|
|
||||||
}MB`,
|
|
||||||
"error",
|
"error",
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
export const maximumAttachmentSize = 1024 * 1024 * 10; // 10MB
|
export const maximumAttachmentSize = 10; // MiB
|
Loading…
Reference in New Issue