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