Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.
TypeScript cloud-alternativecollaborationcollaborative-editingdropboxfile-serverfile-sharingfile-storagefile-syncfull-text-searchhomelabnextcloudon-premiseopen-sourceprivacy-firstprivate-cloudrealtimesecureself-hostedstorage-serverwebdav
fix(backend:files): align HEAD and GET encoding for downloads
johaven67667f6e538d
diff --git a/backend/src/applications/files/utils/download-file.spec.ts b/backend/src/applications/files/utils/download-file.spec.tsindex f8c82c63..ad46a4a9 100644--- a/backend/src/applications/files/utils/download-file.spec.ts+++ b/backend/src/applications/files/utils/download-file.spec.ts@@ -154,6 +154,8 @@ describe(DownloadFile.name, () => {expect(http.axiosRef).toHaveBeenCalledTimes(1)expect(http.axiosRef).toHaveBeenCalledWith(expect.objectContaining({+ decompress: false,+ headers: { 'Accept-Encoding': 'identity' },httpAgent: expect.any(Object),httpsAgent: expect.any(Object)})diff --git a/backend/src/applications/files/utils/download-file.ts b/backend/src/applications/files/utils/download-file.tsindex 463cd77f..86476185 100644--- a/backend/src/applications/files/utils/download-file.ts+++ b/backend/src/applications/files/utils/download-file.ts@@ -45,7 +45,13 @@ export class DownloadFile {options?: { allowPrivateIP?: boolean; space?: SpaceEnv; getContentInfo?: false | undefined }): Promise<void>async download(downloadDto: DownloadFileDto, dstPath: string, options?: DownloadFileOptions): Promise<void | DownloadFileContentInfo> {- const { response: headRes, url } = await this.request(downloadDto.url, { method: HTTP_METHOD.HEAD }, { allowPrivateIP: options?.allowPrivateIP })+ const identityEncodingConfig = { decompress: false, headers: { 'Accept-Encoding': 'identity' } }++ const { response: headRes, url } = await this.request(+ downloadDto.url,+ { method: HTTP_METHOD.HEAD, ...identityEncodingConfig },+ { allowPrivateIP: options?.allowPrivateIP }+ )const headers = AxiosHeaders.from(headRes.headers)const contentLength = this.contentLength(headers)@@ -63,7 +69,7 @@ export class DownloadFile {// The HEAD request resolved redirects; the GET must target that final URL directly.const { response: getRes } = await this.request(url,- { method: HTTP_METHOD.GET, responseType: 'stream', decompress: false, headers: { 'Accept-Encoding': 'identity' } },+ { method: HTTP_METHOD.GET, responseType: 'stream', ...identityEncodingConfig },{ allowPrivateIP: options?.allowPrivateIP, maxRedirects: 0 })await writeFromStream(dstPath, getRes.data, 0, contentLength)