I have been trying to send an image captured using camera plugin in flutter. I think the add_resource function should contain a parameter for image path. I tried the same for normal string format which is working and the code is as follows:

 class UploadImage(Resource):
  def post(self):
    file=request.files['file']
    if file:
      pass
    else:
      return {"data":"False"}

api.add_resource(UploadImage,"/uploadimage/<string:fname>")

The code for capturing the image in flutter is as follows:

child: ElevatedButton(
                    onPressed: () async {
                      pictureFile = await controller.takePicture();
                      File file = File(pictureFile!.path);
                      await uploadImage(file);
                      Image img= Image.file(file);
                      //final String path=await getApplicationDocumentsDirectory().path;
                      // final String fileName=basename(img.path);
                      // final String imgpath=file.path;
                      // final File localImg=await file.copy('$imgpath/$fileName');

                      Navigator.of(context).push(
                          MaterialPageRoute(builder: (context) =>
                              DisplayPicture(imagePath: pictureFile!.path,))
                      );
                      setState(() {});
                    },
                    child: const Text('Capture Image'),
                  ),

This is the upload function in flutter which sends image to flask rest-api.

uploadImage(File img) async{
    final request=http.MultipartRequest("POST",Uri.parse("http://127.0.0.1:5000/uploadimage/"));
    //final headers={"Content-type":"multipart/form-data"};

    request.files.add(http.MultipartFile('image',img.readAsBytes().asStream(),
        img.lengthSync(),filename: img.path.split("/").last));
    // http.StreamedResponse response=await request.send();
    http.StreamedResponse streamedResponse = await request.send();
    http.Response response = await http.Response.fromStream(streamedResponse);
    //latest added code
    final resJson=jsonDecode(response.body);
    message=resJson['message'];
    print(response.statusCode);
  }

Any help would be really appreciated :P