return download url
This commit is contained in:
@@ -48,6 +48,7 @@ type ApiFile = {
|
||||
status: string;
|
||||
protectStatus: string;
|
||||
supportId: number;
|
||||
fileName: string;
|
||||
};
|
||||
|
||||
type ApiResponse = {
|
||||
@@ -474,8 +475,7 @@ export default function TanstakFilesTable({ fileType }: { fileType: string }) {
|
||||
setIsFileLoading(true);
|
||||
|
||||
try {
|
||||
/* const response = await fetch(`/api/download/${file.id}`); */
|
||||
const response = await fetch(`/api/v1/files/download/${file.id}`);
|
||||
const response = await fetch(`/api/download/${file.id}`);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`error: ${response.status}`);
|
||||
@@ -485,7 +485,7 @@ export default function TanstakFilesTable({ fileType }: { fileType: string }) {
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = file.fileName || `file-${file.id}`;
|
||||
a.download = file._original?.fileName || file.fileName || `file-${file.id}`;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
window.URL.revokeObjectURL(url);
|
||||
|
||||
Reference in New Issue
Block a user