From 8608773cc18ef90342af4b8d85a1c3183f1e2daf Mon Sep 17 00:00:00 2001 From: book33 Date: Tue, 5 Sep 2023 17:30:42 +0800 Subject: [PATCH] Fix: add response type with arraybuffer readBinary call (#15) --- .../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) {