I am trying to upload an image to images from Flutter and is loading everything, but at the end gives me 400 error:
My code:
flutter: {“result”:{“id”:“920f707a-4bf6-41b1-929b-01e0b5884e00”,“uploadURL”:“https:///upload.imagedelivery.net/5nQCQxwFZix2EchBu-AKmg/920f707a-4bf6-41b1-929b-01e0b5884e00”},“result_info”:null,“success”:true,“errors”:,“messages”:}
The query for the one time upload URL looks like this:
Looks correct according to the docs
final result = await requestDirectUploadLink();
var url = result.data[‘result’][‘uploadURL’];
var imageId = result.data[‘result’][‘id’];
var form = FormData.fromMap({
‘image’: await MultipartFile.fromFile(imagePath),
});
try {
final response = dio.post(url,
data: form, onSendProgress: progress, options: uploadAuth);
debugPrint(response.toString());
} on Exception catch (_, e) {
debugPrint(‘Exception Cloudflare $e’);
}
url is the one time upload URL fetched from the server.
Curiuosly it shows me the whole progress but at the end gives me a 400 error…
flutter: DioError [DioErrorType.response]: Http status error [400]
Source stack:
#0 DioMixin.fetch (package:dio/src/dio_mixin.dart:488:35)
#1 DioMixin.request (package:dio/src/dio_mixin.dart:483:12)
#2 DioMixin.post (package:dio/src/dio_mixin.dart:97:12)
#3 CloudflareApi.uploadImage (package:petme/cloudfare/api.dart:52:28)