binaryDataByIds method

Future<BinaryDataByIDsResponse> binaryDataByIds(
  1. List<BinaryID> binaryIds, {
  2. bool includeBinary = false,
})

Retrieve binary data by IDs

 _viam = await Viam.withApiKey(
     dotenv.env['API_KEY_ID'] ?? '',
     dotenv.env['API_KEY'] ?? ''
 );
 final dataClient = _viam.dataClient;

 try {
  final binaryIDs = [
   BinaryID(fileId: '<YOUR-FILE-ID>', organizationId: '<YOUR-ORG-ID>', locationId: '<YOUR-LOCATION-ID>'),
   BinaryID(fileId: '<YOUR-FILE-ID>', organizationId: '<YOUR-ORG-ID>', locationId: '<YOUR-LOCATION-ID>')
  ];

  final response = await dataClient.binaryDataByIds(
    binaryIDs,
    includeBinary: true
  );

  for (var dataPoint in response.data) {
    print(dataPoint.binary);
    print(dataPoint.metadata);
  }

  print('Successfully retrieved binary data by IDs');
 } catch (e) {
  print('Error retrieving binary data by IDs: $e');
 }

For more information, see Data Client API.

Implementation

Future<BinaryDataByIDsResponse> binaryDataByIds(List<BinaryID> binaryIds, {bool includeBinary = false}) async {
  final request = BinaryDataByIDsRequest()
    ..binaryIds.addAll(binaryIds)
    ..includeBinary = includeBinary;
  final response = await _dataClient.binaryDataByIDs(request);
  return response;
}