Skip to content

Commit

Permalink
fix: download multiparts
Browse files Browse the repository at this point in the history
  • Loading branch information
richardmichel committed May 25, 2023
1 parent 33847d2 commit 7a5ed22
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
6 changes: 4 additions & 2 deletions src/components/DownloadFile/DownloadFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import { AbortController } from '../UploadFile/AbortController';
export interface detailProps {
fileStatus: number;
isDownload: boolean;
preSignedUrl?: string | null;
urlGet: string;
urlHead: string;
progress: number;
urlService: string;
}
Expand Down Expand Up @@ -198,7 +199,8 @@ export class DownloadFile extends Evented {
this.downloader = new Downloader({
...downloaderOptions,
params: {
url: downloaderOptions.preSignedUrl,
urlGet: downloaderOptions.urlGet,
urlHead: downloaderOptions.urlHead,
},
controller: this.controller,
urlService: downloaderOptions.urlService
Expand Down
8 changes: 3 additions & 5 deletions src/components/DownloadFile/downloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,9 @@ export class Downloader {
xhr.addEventListener('abort', progressListener);
xhr.addEventListener('loadend', progressListener);

// const parameters = `url=${encodeURIComponent(params.url)}`;


xhr.open('GET', params.url , true); // `${this.urlService}?${parameters}`
xhr.open('GET', params.urlGet , true);

xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
// xhr.setRequestHeader('Authorization', this.token)
Expand Down Expand Up @@ -390,11 +390,9 @@ export class Downloader {
getContentLength(params: any) {
return new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest();
// xhr.withCredentials = true;

// const parameters = `url=${encodeURIComponent(params.url)}`;

xhr.open('HEAD', params.url); // `${this.urlService}?${parameters}`
xhr.open('HEAD', params.urlHead);

xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
// xhr.setRequestHeader('Authorization', token)
Expand Down
8 changes: 6 additions & 2 deletions src/components/useFileDownloadS3Multipart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ export const useFileDownloadS3Multipart = ({
const getFile = async (fileUUID: string) => {
try {
// @ts-ignore
const { preSignedUrl } =
const { preSignedUrls : {
urlGet,
urlHead
} } =
await TransferService.generateDownloadSignedUrl({
fileUUID,
urlService,
Expand All @@ -46,7 +49,8 @@ export const useFileDownloadS3Multipart = ({
const detail = {
fileStatus: PENDING_STATUS,
isDownload: true,
preSignedUrl,
urlGet,
urlHead,
progress: 0,
urlService
};
Expand Down

0 comments on commit 7a5ed22

Please sign in to comment.