uploadToGCS method

Future<PixelBinImage?> uploadToGCS(
  1. String url,
  2. Map<String, String> fields,
  3. File file
)

Implementation

Future<PixelBinImage?> uploadToGCS(
    String url, Map<String, String> fields, File file) async {
  var uri = Uri.parse(url);
  var request = http.Request('PUT', uri);

  fields.forEach((key, value) {
    request.headers[key] = value;
  });

  request.bodyBytes = await file.readAsBytes();
  var response = await request.send();
  if (response.statusCode != 200) {
    throw Exception('Failed to upload to GCS');
  }
  return null;
}