Skip to content

Commit

Permalink
Refactor file download logic in useDropzoneInputComponents
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielARamosDev committed Jan 30, 2024
1 parent db969a7 commit c40da74
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/components/DropzoneInputComponents.hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,23 @@ export default function useDropzoneInputComponents() {
if (isLocal) {
window.open(`/storage/files/${file}` as string);
} else {
const filename = (file as UploadedFile).filename.split('.')[0];

const response = await axios({
url: route('api.file.download', { folder, filename }),
url: route(
'api.file.download',
{ folder, filename: (file as UploadedFile).filename }
),
method: 'GET',
responseType: 'blob',
});
// console.log({ response });

const fileBlob = new Blob([response.data]);
const filename = (file as UploadedFile)?.name.split('.')[0];
const fileBlob = response.data;

console.log({
filename,
useDownloadBlob(
fileBlob,
});

// useDownloadBlob(
// fileBlob,
// filename,
// );
filename,
);
}
};

Expand Down

0 comments on commit c40da74

Please sign in to comment.