Add api prefix to attachment nodes
This commit is contained in:
parent
a7dd9b9198
commit
16254802e3
6 changed files with 15 additions and 6 deletions
|
|
@ -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,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue