From b81ce9300b55e35c584496ec0e3f38d129c09df3 Mon Sep 17 00:00:00 2001 From: Book Chang Date: Fri, 12 May 2023 13:46:00 +0800 Subject: [PATCH] Fix: add response type with arraybuffer readBinary call --- .../LabelingUX/Client/src/providers/storageProvider.test.ts | 4 +++- SampleCode/LabelingUX/Client/src/providers/storageProvider.ts | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/SampleCode/LabelingUX/Client/src/providers/storageProvider.test.ts b/SampleCode/LabelingUX/Client/src/providers/storageProvider.test.ts index c0974f9..283a265 100644 --- a/SampleCode/LabelingUX/Client/src/providers/storageProvider.test.ts +++ b/SampleCode/LabelingUX/Client/src/providers/storageProvider.test.ts @@ -45,7 +45,9 @@ describe("StorageProvider", () => { it("should handle readBinary", async () => { await provider.readBinary(mockFilename); - expect(RequestHelper.getWithAutoRetry).toBeCalledWith(`${serverUrl}/files/${mockFilename}`); + expect(RequestHelper.getWithAutoRetry).toBeCalledWith(`${serverUrl}/files/${mockFilename}`, { + responseType: "arraybuffer", + }); }); it("should handle writeText", async () => { diff --git a/SampleCode/LabelingUX/Client/src/providers/storageProvider.ts b/SampleCode/LabelingUX/Client/src/providers/storageProvider.ts index c9882e5..ff3ea74 100644 --- a/SampleCode/LabelingUX/Client/src/providers/storageProvider.ts +++ b/SampleCode/LabelingUX/Client/src/providers/storageProvider.ts @@ -64,7 +64,7 @@ export class StorageProvider implements IStorageProvider { public async readBinary(filename: string, ignoreNotFound?: boolean): Promise { try { const api = `${serverUrl}/files/${filename}`; - const result = await getWithAutoRetry(api); + const result = await getWithAutoRetry(api, { responseType: "arraybuffer" }); return result.data; } catch (exception) {