Skip to content

Instantly share code, notes, and snippets.

@epietrowicz
Last active May 1, 2020 14:19
Show Gist options
  • Save epietrowicz/7866712bb540ae0601ddf0240389e7cf to your computer and use it in GitHub Desktop.
Save epietrowicz/7866712bb540ae0601ddf0240389e7cf to your computer and use it in GitHub Desktop.
filling in upload function
final String endPoint = 'http://10.0.2.2:8000/analyze';
void _upload(File file) async {
String fileName = file.path.split('/').last;
print(fileName);
FormData data = FormData.fromMap({
"file": await MultipartFile.fromFile(
file.path,
filename: fileName,
),
});
Dio dio = new Dio();
dio.post(endPoint, data: data).then((response) {
var jsonResponse = jsonDecode(response.toString());
var testData = jsonResponse['histogram_counts'].cast<double>();
var averageGrindSize = jsonResponse['average_particle_size'];
}).catchError((error) => print(error));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment