-
-
Save marcossevilla/1bfdb3eb32a894a0007f7607708d66b7 to your computer and use it in GitHub Desktop.
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 client = Dio(); | |
final url = 'https://some-api.dev/'; | |
final directory = await getTemporaryDirectory(); | |
final fileName = '${directory.path}/rant_about_the_world.txt'; | |
final payload = FormData.fromMap({ | |
'user': 'marcossevilla', | |
'essay': await MultipartFile.fromFile(fileName), | |
}); | |
await client.post( | |
'$url/user/new', | |
data: payload, | |
onSendProgress: (sent, total) { | |
final progress = sent / total * 100; | |
print(progress); | |
}, | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment