I'm trying to upload an image to Strapi through Flutter Web. I'm aware (from this link) that I need to use FormData to do so. I've researched on many ways to do this and I stumble across Dio and of course Http.
Both solutions gave me errors:
Unsupported operation: MultipartFile is only supported where dart:io is available.
I've tried this code:
var request = new http.MultipartRequest("POST", Uri.parse(url));
request.files.add(
await http.MultipartFile.fromPath(
"files",
imageFilePath,
),
);
request.send().then((response) {
if (response.statusCode == 200) print("Uploaded!");
print(response.statusCode);
}).catchError((e) => print(e));
As suggested here.
And many other getting errors or Empty Data (400), when I use MultipartFile.fromBytes(...)
.
I'm just trying to upload a file, therefore I assume my body should only contain the FormData with as files
as it's mentioned on Strapi's Documentation.