Good day I know that this has been answered, but I'm still unable to figure out what's wrong with my code. I would like some help on how to upload a single image file using dio. I'm able to send the request successfully but the response does not contain the image.
but when I send using postman all works just fine.
import 'package:dio/dio.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
class Upload{
static Future<bool> wall_add(owner_guid, poster_guid, post, tags, privacy, type, photo) async {
var fileName = photo.path.split('/').last;
FormData data = FormData.fromMap({
"ossn_photo": await MultipartFile.fromFile(
photo.path,
filename: fileName,
),
"api_key_token" : env['API_KEY'],
"owner_guid" : owner_guid,
"poster_guid" : poster_guid,
"type" : type,
});
Dio dio = Dio();
dio.post("${env['URL']}/wall_add", data: data)
.then((response) {
print(response);
return (true);
})
.catchError((error) => print(error));
return (false);
}
}