uploadFile method
Upload a file that contains document(s) to be used across various endpoints/features. Currently, the size of all the files uploaded by one organization can be up to 1 GB.
Implementation
Future<FileData> uploadFile(
{required String apiKey,
required File file,
required String purpose}) async {
final formData = FormData.fromMap({
'purpose': purpose,
'file': await MultipartFile.fromFile(file.path),
});
final response = await dio.post(UrlBuilder.filesPath,
data: formData,
options: Options(headers: {
'Content-Type': 'multpart/form-data',
'Authorization': 'Bearer $apiKey'
}));
return FileData.fromMap(response.data);
}