mirror of
https://github.com/docmost/docmost.git
synced 2025-11-25 09:01:08 +10:00
Compare commits
2 Commits
be0d97661a
...
dea9f4c063
| Author | SHA1 | Date | |
|---|---|---|---|
| dea9f4c063 | |||
| 0b6730c06f |
@ -64,7 +64,7 @@ export async function exportPage(data: IExportPageParams): Promise<void> {
|
|||||||
.split("filename=")[1]
|
.split("filename=")[1]
|
||||||
.replace(/"/g, "");
|
.replace(/"/g, "");
|
||||||
|
|
||||||
saveAs(req.data, fileName);
|
saveAs(req.data, decodeURIComponent(fileName));
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function importPage(file: File, spaceId: string) {
|
export async function importPage(file: File, spaceId: string) {
|
||||||
@ -81,14 +81,17 @@ export async function importPage(file: File, spaceId: string) {
|
|||||||
return req.data;
|
return req.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function uploadFile(file: File, pageId: string, attachmentId?: string): Promise<IAttachment> {
|
export async function uploadFile(
|
||||||
|
file: File,
|
||||||
|
pageId: string,
|
||||||
|
attachmentId?: string,
|
||||||
|
): Promise<IAttachment> {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
if(attachmentId){
|
if (attachmentId) {
|
||||||
formData.append("attachmentId", attachmentId);
|
formData.append("attachmentId", attachmentId);
|
||||||
}
|
}
|
||||||
formData.append("pageId", pageId);
|
formData.append("pageId", pageId);
|
||||||
formData.append("file", file);
|
formData.append("file", file);
|
||||||
|
|
||||||
|
|
||||||
const req = await api.post<IAttachment>("/files/upload", formData, {
|
const req = await api.post<IAttachment>("/files/upload", formData, {
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@ -182,7 +182,7 @@ export class AttachmentController {
|
|||||||
if (!inlineFileExtensions.includes(attachment.fileExt)) {
|
if (!inlineFileExtensions.includes(attachment.fileExt)) {
|
||||||
res.header(
|
res.header(
|
||||||
'Content-Disposition',
|
'Content-Disposition',
|
||||||
`attachment; filename="${attachment.fileName}"`,
|
`attachment; filename="${encodeURIComponent(attachment.fileName)}"`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -61,7 +61,8 @@ export class ImportController {
|
|||||||
|
|
||||||
res.headers({
|
res.headers({
|
||||||
'Content-Type': getMimeType(fileExt),
|
'Content-Type': getMimeType(fileExt),
|
||||||
'Content-Disposition': 'attachment; filename="' + fileName + '"',
|
'Content-Disposition':
|
||||||
|
'attachment; filename="' + encodeURIComponent(fileName) + '"',
|
||||||
});
|
});
|
||||||
|
|
||||||
res.send(rawContent);
|
res.send(rawContent);
|
||||||
|
|||||||
Reference in New Issue
Block a user