(blobName: string, containerClient: ContainerClient)
| 21 | } |
| 22 | |
| 23 | async function blobNameToMetadata(blobName: string, containerClient: ContainerClient): Promise<SigMFMetadata> { |
| 24 | const fName = blobName.split('.')[0]; |
| 25 | const blobClient = containerClient.getBlobClient(fName + '.sigmf-meta'); |
| 26 | let blobBody = await (await blobClient.download()).blobBody; |
| 27 | let recording: SigMFMetadata | null = null; |
| 28 | try { |
| 29 | let jsonString = await readBlobAsText(blobBody); |
| 30 | let objectFromJson = JSON.parse(jsonString); |
| 31 | recording = Object.assign(new SigMFMetadata(), objectFromJson); |
| 32 | } catch (e) { |
| 33 | console.error(e); |
| 34 | } |
| 35 | if (!recording) { |
| 36 | return null; |
| 37 | } |
| 38 | const blobDataClient = containerClient.getBlobClient(fName + '.sigmf-data'); |
| 39 | recording.dataClient = blobDataClient; |
| 40 | let properties = await blobDataClient.getProperties(); |
| 41 | if (!recording) { |
| 42 | return null; |
| 43 | } |
| 44 | if (!recording.global['traceability:sample_length']) { |
| 45 | recording.global['traceability:sample_length'] = Math.round( |
| 46 | properties.contentLength / recording.getBytesPerIQSample() |
| 47 | ); |
| 48 | } |
| 49 | if (!recording.global['traceability:origin']) { |
| 50 | recording.global['traceability:origin'] = { |
| 51 | type: 'azure_blob', |
| 52 | account: containerClient.accountName, |
| 53 | container: containerClient.containerName, |
| 54 | file_path: fName, |
| 55 | }; |
| 56 | } |
| 57 | recording.annotations = recording.annotations.map((annotation) => Object.assign(new Annotation(), annotation)); |
| 58 | recording.captures = recording.captures.map((capture) => Object.assign(new CaptureSegment(), capture)); |
| 59 | return recording; |
| 60 | } |
| 61 | |
| 62 | export class BlobClient implements MetadataClient { |
| 63 | dataSources: Record<string, DataSource>; |
no test coverage detected