Use backend endpoint for attachment downloads

This commit is contained in:
TerryM
2026-05-27 12:17:47 +08:00
parent 68cbce9cf1
commit 9453777dba
5 changed files with 42 additions and 23 deletions

View File

@@ -1,8 +1,7 @@
import { ArrowDownToLine } from "lucide-react";
import { postNoBody } from "../../../api";
import { useI18n } from "../../../i18n";
import type { Attachment, Post } from "../../../types/post";
import { downloadFile } from "../utils/downloadFile";
import { downloadAttachment } from "../utils/downloadFile";
import { fileIcon } from "../utils/fileIcon";
import {
filenameWithExtension,
@@ -17,8 +16,7 @@ function AttachmentRow({ postId, att }: { postId: string; att: Attachment }) {
const displayFilename = filenameWithExtension(att.filename, att.mime);
const handleDownload = () => {
void postNoBody(`/api/posts/${postId}/attachments/${att.id}/download`);
void downloadFile(att.url, displayFilename).catch(() => {});
void downloadAttachment(postId, att.id, displayFilename).catch(() => {});
};
return (