uploadAttachment method

Future<String> uploadAttachment(
  1. String attachmentBase64,
  2. String filename
)

Implementation

Future<String> uploadAttachment(
  String attachmentBase64,
  String filename,
) async {
  final response = await _dio.post(
    ApiConstants.geminiUploadAttachment(model),
    options: Options(
      headers: {
        'Authorization': 'Bearer $apiKey',
        'Content-Type': 'application/json',
      },
    ),
    data: {'attachment': attachmentBase64, 'filename': filename},
  );
  if (response.statusCode == 200) {
    return response.data['attachmentId'] ?? '';
  } else {
    throw Exception('Failed to upload attachment: \n${response.data}');
  }
}