Adds an option in SETTINGS to change the maximum size of file you can upload to your space. (#832)
parent
331d526f52
commit
e280dfee4a
|
@ -32,6 +32,7 @@ export function parseYamlSettings(settingsMarkdown: string): {
|
|||
export const defaultSettings: BuiltinSettings = {
|
||||
indexPage: "index",
|
||||
hideSyncButton: false,
|
||||
maximumAttachmentSize: 10, // MiB
|
||||
actionButtons: [
|
||||
{
|
||||
icon: "Home",
|
||||
|
|
|
@ -1,18 +1,22 @@
|
|||
import { readSetting } from "$sb/lib/settings_page.ts";
|
||||
import { editor, space } from "$sb/syscalls.ts";
|
||||
import { UploadFile } from "../../plug-api/types.ts";
|
||||
|
||||
const maximumAttachmentSize = 1024 * 1024 * 10; // 10MB
|
||||
const maximumAttachmentSize = 10; // MiB
|
||||
|
||||
function folderName(path: string) {
|
||||
return path.split("/").slice(0, -1).join("/");
|
||||
}
|
||||
|
||||
async function saveFile(file: UploadFile) {
|
||||
if (file.content.length > maximumAttachmentSize) {
|
||||
const maxSize = await readSetting("maximumAttachmentSize", maximumAttachmentSize);
|
||||
if (typeof maxSize !== "number") {
|
||||
await editor.flashNotification(
|
||||
"The setting 'maximumAttachmentSize' must be a number", "error");
|
||||
}
|
||||
if (file.content.length > 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;
|
||||
|
|
|
@ -17,6 +17,7 @@ export type BuiltinSettings = {
|
|||
plugOverrides?: Record<string, Partial<Manifest>>;
|
||||
shortcuts?: Shortcut[];
|
||||
hideSyncButton?: boolean;
|
||||
maximumAttachmentSize?: number;
|
||||
actionButtons: ActionButton[];
|
||||
// Format: compatible with docker ignore
|
||||
spaceIgnore?: string;
|
||||
|
|
|
@ -42,6 +42,9 @@ spaceIgnore: |
|
|||
largefolder
|
||||
*.mp4
|
||||
|
||||
# Defines the maximum size of a file you can upload to the space (in MiB)
|
||||
maximumAttachmentSize: 10
|
||||
|
||||
# Add alternative names to emoji picker
|
||||
emoji:
|
||||
aliases:
|
||||
|
|
Loading…
Reference in New Issue