Skip to content

Instantly share code, notes, and snippets.

@gladson
Created August 4, 2021 19:26
Show Gist options
  • Save gladson/aacb23f577b458591d485b3c129dcd42 to your computer and use it in GitHub Desktop.
Save gladson/aacb23f577b458591d485b3c129dcd42 to your computer and use it in GitHub Desktop.
SEND ARQUIVO - API
uploadFile() async {
var postUri = Uri.parse("<APIUrl>");
var request = new http.MultipartRequest("POST", postUri);
request.fields['user'] = 'blah';
request.files.add(new http.MultipartFile.fromBytes('file', await File.fromUri("<path/to/file>").readAsBytes(), contentType: new MediaType('image', 'jpeg')))
request.send().then((response) {
if (response.statusCode == 200) print("Uploaded!");
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment