Last active
May 1, 2020 14:19
-
-
Save epietrowicz/7866712bb540ae0601ddf0240389e7cf to your computer and use it in GitHub Desktop.
filling in upload function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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