uploadMultiple method

Future<List<CloudflareHTTPResponse<CloudflareImage?>>> uploadMultiple({
  1. List<DataTransmit<File>>? contentFromFiles,
  2. List<DataTransmit<String>>? contentFromPaths,
  3. List<DataTransmit<Uint8List>>? contentFromBytes,
  4. List<DataTransmit<String>>? contentFromUrls,
  5. bool? requireSignedURLs,
  6. Map<String, dynamic>? metadata,
})

Uploads multiple images by repeatedly calling upload

Implementation

Future<List<CloudflareHTTPResponse<CloudflareImage?>>> uploadMultiple({
  /// Image files to upload
  List<DataTransmit<File>>? contentFromFiles,

  /// Paths to the image files to upload
  List<DataTransmit<String>>? contentFromPaths,

  /// List of image byte array representations to upload
  List<DataTransmit<Uint8List>>? contentFromBytes,

  /// List of image urls to upload
  List<DataTransmit<String>>? contentFromUrls,

  /// Indicates whether the image requires a signature token for the access
  /// default value: false
  /// valid values: (true,false)
  bool? requireSignedURLs,

  /// User modifiable key-value store. Can use used for keeping references to
  /// another system of record for managing images.
  /// "{\"meta\": \"metaID\"}"
  Map<String, dynamic>? metadata,
}) async {
  assert(!isBasic, RestAPIService.authorizedRequestAssertMessage);
  assert(
      (contentFromFiles?.isNotEmpty ?? false) ||
          (contentFromPaths?.isNotEmpty ?? false) ||
          (contentFromBytes?.isNotEmpty ?? false) ||
          (contentFromUrls?.isNotEmpty ?? false),
      'One of the contents must be specified.');

  List<CloudflareHTTPResponse<CloudflareImage?>> responses = [];

  if (contentFromPaths?.isNotEmpty ?? false) {
    contentFromFiles = [];
    for (final content in contentFromPaths!) {
      contentFromFiles.add(DataTransmit<File>(
          data: File(content.data),
          progressCallback: content.progressCallback));
    }
  }
  if (contentFromFiles?.isNotEmpty ?? false) {
    for (final content in contentFromFiles!) {
      final response = await upload(
        contentFromFile: content,
        requireSignedURLs: requireSignedURLs,
        metadata: metadata,
      );
      responses.add(response);
    }
  } else if (contentFromBytes?.isNotEmpty ?? false) {
    for (final content in contentFromBytes!) {
      final response = await upload(
        contentFromBytes: content,
        requireSignedURLs: requireSignedURLs,
        metadata: metadata,
      );
      responses.add(response);
    }
  } else {
    for (final content in contentFromUrls!) {
      final response = await upload(
        contentFromUrl: content,
        requireSignedURLs: requireSignedURLs,
        metadata: metadata,
      );
      responses.add(response);
    }
  }
  return responses;
}