diff --git a/packages/app/src/providers/h5grove/__snapshots__/h5grove-api.test.ts.snap b/packages/app/src/providers/h5grove/__snapshots__/h5grove-api.test.ts.snap index 8098df706..d5edccc72 100644 --- a/packages/app/src/providers/h5grove/__snapshots__/h5grove-api.test.ts.snap +++ b/packages/app/src/providers/h5grove/__snapshots__/h5grove-api.test.ts.snap @@ -796,7 +796,7 @@ exports[`test file matches snapshot 1`] = ` "class": "Opaque", "tag": "", }, - "value": """, + "value": [AxiosError: Request failed with status code 422], }, { "name": "byte_string_1D", @@ -813,11 +813,7 @@ exports[`test file matches snapshot 1`] = ` "class": "Opaque", "tag": "", }, - "value": [ - "", - "", - """, - ], + "value": [AxiosError: Request failed with status code 422], }, { "name": "datetime64_scalar", @@ -832,7 +828,7 @@ exports[`test file matches snapshot 1`] = ` "class": "Opaque", "tag": "", }, - "value": [AxiosError: Request failed with status code 500], + "value": [AxiosError: Request failed with status code 422], }, { "name": "datetime64_not-a-time_scalar", @@ -847,7 +843,7 @@ exports[`test file matches snapshot 1`] = ` "class": "Opaque", "tag": "", }, - "value": [AxiosError: Request failed with status code 500], + "value": [AxiosError: Request failed with status code 422], }, { "name": "complex64_scalar", diff --git a/packages/app/src/providers/h5grove/h5grove-api.ts b/packages/app/src/providers/h5grove/h5grove-api.ts index 5e77beebf..0e166939e 100644 --- a/packages/app/src/providers/h5grove/h5grove-api.ts +++ b/packages/app/src/providers/h5grove/h5grove-api.ts @@ -7,6 +7,7 @@ import type { ProvidedEntity, Value, } from '@h5web/shared/hdf5-models'; +import { DTypeClass } from '@h5web/shared/hdf5-models'; import type { AxiosRequestConfig } from 'axios'; import { DataProviderApi } from '../api'; @@ -45,9 +46,13 @@ export class H5GroveApi extends DataProviderApi { ): Promise { const { dataset } = params; + if (dataset.type.class === DTypeClass.Opaque) { + return new Uint8Array(await this.fetchBinaryData(params)); + } + const DTypedArray = h5groveTypedArrayFromDType(dataset.type); if (DTypedArray) { - const buffer = await this.fetchBinaryData(params); + const buffer = await this.fetchBinaryData(params, true); const array = new DTypedArray(buffer); return hasScalarShape(dataset) ? array[0] : array; } @@ -149,6 +154,7 @@ export class H5GroveApi extends DataProviderApi { private async fetchBinaryData( params: ValuesStoreParams, + safe = false, ): Promise { const { data } = await this.cancellableFetchValue( '/data/', @@ -157,7 +163,7 @@ export class H5GroveApi extends DataProviderApi { path: params.dataset.path, selection: params.selection, format: 'bin', - dtype: 'safe', + dtype: safe ? 'safe' : undefined, }, 'arraybuffer', );