Created
August 4, 2021 19:26
-
-
Save gladson/aacb23f577b458591d485b3c129dcd42 to your computer and use it in GitHub Desktop.
SEND ARQUIVO - API
This file contains hidden or 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
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