I need to pass an image file that I have taken from the camera, directly as param with a POST method in Flutter.
Asked
Active
Viewed 204 times
-1
-
2Have you read https://stackoverflow.com/questions/44841729/how-to-upload-image-in-flutter? – Carlos Menezes Aug 01 '20 at 10:24
-
2Duplicate question - https://stackoverflow.com/questions/51161862/how-to-send-an-image-to-an-api-in-dart-flutter – Zeeshan Hussain Aug 01 '20 at 10:24
-
Could you share what have you tried so far? You can post your code here. – Mariano Zorrilla Aug 01 '20 at 16:43
1 Answers
1
You can use MultipartFile
from the http
library
var request = http.MultipartRequest('POST', Uri.parse('YourUrl'));
request.files.add(
http.MultipartFile.fromBytes(
'YourField',
File('YourFilename').readAsBytesSync(),
filename: 'YourFilename'
)
);
var res = await request.send();

HBS
- 580
- 3
- 6