mirror of
https://github.com/docmost/docmost.git
synced 2026-05-07 06:23:06 +08:00
Add api prefix to attachment nodes
This commit is contained in:
@@ -77,7 +77,7 @@ export default function DrawioView(props: NodeViewProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateAttributes({
|
updateAttributes({
|
||||||
src: `/files/${attachment.id}/${attachment.fileName}?t=${new Date(attachment.updatedAt).getTime()}`,
|
src: `/api/files/${attachment.id}/${attachment.fileName}?t=${new Date(attachment.updatedAt).getTime()}`,
|
||||||
title: attachment.fileName,
|
title: attachment.fileName,
|
||||||
size: attachment.fileSize,
|
size: attachment.fileSize,
|
||||||
attachmentId: attachment.id,
|
attachmentId: attachment.id,
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ export default function ExcalidrawView(props: NodeViewProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateAttributes({
|
updateAttributes({
|
||||||
src: `/files/${attachment.id}/${attachment.fileName}?t=${new Date(attachment.updatedAt).getTime()}`,
|
src: `/api/files/${attachment.id}/${attachment.fileName}?t=${new Date(attachment.updatedAt).getTime()}`,
|
||||||
title: attachment.fileName,
|
title: attachment.fileName,
|
||||||
size: attachment.fileSize,
|
size: attachment.fileSize,
|
||||||
attachmentId: attachment.id,
|
attachmentId: attachment.id,
|
||||||
|
|||||||
@@ -53,7 +53,16 @@ export function getSpaceUrl(spaceSlug: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getFileUrl(src: string) {
|
export function getFileUrl(src: string) {
|
||||||
return src?.startsWith("/files/") ? getBackendUrl() + src : src;
|
if (!src) return src;
|
||||||
|
if (src.startsWith("http")) return src;
|
||||||
|
if (src.startsWith("/api/")) {
|
||||||
|
// Remove the '/api' prefix
|
||||||
|
return getBackendUrl() + src.substring(4);
|
||||||
|
}
|
||||||
|
if (src.startsWith("/files/")) {
|
||||||
|
return getBackendUrl() + src;
|
||||||
|
}
|
||||||
|
return src;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getFileUploadSizeLimit() {
|
export function getFileUploadSizeLimit() {
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ export const handleAttachmentUpload =
|
|||||||
if (!attachment) return;
|
if (!attachment) return;
|
||||||
|
|
||||||
const node = schema.nodes.attachment?.create({
|
const node = schema.nodes.attachment?.create({
|
||||||
url: `/files/${attachment.id}/${attachment.fileName}`,
|
url: `/api/files/${attachment.id}/${attachment.fileName}`,
|
||||||
name: attachment.fileName,
|
name: attachment.fileName,
|
||||||
mime: attachment.mimeType,
|
mime: attachment.mimeType,
|
||||||
size: attachment.fileSize,
|
size: attachment.fileSize,
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ export const handleImageUpload =
|
|||||||
if (!attachment) return;
|
if (!attachment) return;
|
||||||
|
|
||||||
const node = schema.nodes.image?.create({
|
const node = schema.nodes.image?.create({
|
||||||
src: `/files/${attachment.id}/${attachment.fileName}`,
|
src: `/api/files/${attachment.id}/${attachment.fileName}`,
|
||||||
attachmentId: attachment.id,
|
attachmentId: attachment.id,
|
||||||
title: attachment.fileName,
|
title: attachment.fileName,
|
||||||
size: attachment.fileSize,
|
size: attachment.fileSize,
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ export const handleVideoUpload =
|
|||||||
if (!attachment) return;
|
if (!attachment) return;
|
||||||
|
|
||||||
const node = schema.nodes.video?.create({
|
const node = schema.nodes.video?.create({
|
||||||
src: `/files/${attachment.id}/${attachment.fileName}`,
|
src: `/api/files/${attachment.id}/${attachment.fileName}`,
|
||||||
attachmentId: attachment.id,
|
attachmentId: attachment.id,
|
||||||
title: attachment.fileName,
|
title: attachment.fileName,
|
||||||
size: attachment.fileSize,
|
size: attachment.fileSize,
|
||||||
|
|||||||
Reference in New Issue
Block a user