mirror of
https://github.com/docmost/docmost.git
synced 2025-11-15 10:31:11 +10:00
make file upload size limit configurable (#386)
This commit is contained in:
@ -1,51 +1,58 @@
|
||||
import bytes from "bytes";
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
CONFIG?: Record<string, string>;
|
||||
}
|
||||
interface Window {
|
||||
CONFIG?: Record<string, string>;
|
||||
}
|
||||
}
|
||||
|
||||
export function getAppUrl(): string {
|
||||
//let appUrl = window.CONFIG?.APP_URL || process.env.APP_URL;
|
||||
//let appUrl = window.CONFIG?.APP_URL || process.env.APP_URL;
|
||||
|
||||
// if (import.meta.env.DEV) {
|
||||
// return appUrl || "http://localhost:3000";
|
||||
//}
|
||||
// if (import.meta.env.DEV) {
|
||||
// return appUrl || "http://localhost:3000";
|
||||
//}
|
||||
|
||||
return `${window.location.protocol}//${window.location.host}`;
|
||||
return `${window.location.protocol}//${window.location.host}`;
|
||||
}
|
||||
|
||||
export function getBackendUrl(): string {
|
||||
return getAppUrl() + '/api';
|
||||
return getAppUrl() + '/api';
|
||||
}
|
||||
|
||||
export function getCollaborationUrl(): string {
|
||||
const COLLAB_PATH = '/collab';
|
||||
const COLLAB_PATH = '/collab';
|
||||
|
||||
let url = getAppUrl();
|
||||
if (import.meta.env.DEV) {
|
||||
url = process.env.APP_URL;
|
||||
}
|
||||
let url = getAppUrl();
|
||||
if (import.meta.env.DEV) {
|
||||
url = process.env.APP_URL;
|
||||
}
|
||||
|
||||
const wsProtocol = url.startsWith('https') ? 'wss' : 'ws';
|
||||
return `${wsProtocol}://${url.split('://')[1]}${COLLAB_PATH}`;
|
||||
const wsProtocol = url.startsWith('https') ? 'wss' : 'ws';
|
||||
return `${wsProtocol}://${url.split('://')[1]}${COLLAB_PATH}`;
|
||||
}
|
||||
|
||||
export function getAvatarUrl(avatarUrl: string) {
|
||||
if (!avatarUrl) {
|
||||
return null;
|
||||
}
|
||||
if (!avatarUrl) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (avatarUrl?.startsWith('http')) {
|
||||
return avatarUrl;
|
||||
}
|
||||
if (avatarUrl?.startsWith('http')) {
|
||||
return avatarUrl;
|
||||
}
|
||||
|
||||
return getBackendUrl() + '/attachments/img/avatar/' + avatarUrl;
|
||||
return getBackendUrl() + '/attachments/img/avatar/' + avatarUrl;
|
||||
}
|
||||
|
||||
export function getSpaceUrl(spaceSlug: string) {
|
||||
return '/s/' + spaceSlug;
|
||||
return '/s/' + spaceSlug;
|
||||
}
|
||||
|
||||
export function getFileUrl(src: string) {
|
||||
return src?.startsWith('/files/') ? getBackendUrl() + src : src;
|
||||
return src?.startsWith('/files/') ? getBackendUrl() + src : src;
|
||||
}
|
||||
|
||||
export function getFileUploadSizeLimit() {
|
||||
const limit = window.CONFIG?.FILE_UPLOAD_SIZE_LIMIT || process?.env.FILE_UPLOAD_SIZE_LIMIT || '50mb';
|
||||
return bytes(limit);
|
||||
}
|
||||
Reference in New Issue
Block a user