Home > Back-end >  How to send a request with file upload in flutter retrofit
How to send a request with file upload in flutter retrofit

Time:05-25

I'm using flutter retrofit package and I need to implement a request as shown in attached postman screenshot

enter image description here

this is what I do, but it didn't work

  @override
  @POST('/update/document')
  @MultiPart()
  Stream<double> uploadDocument(@Part() int id, @Part() File document);

the problem was that the file "document" not added to parameters list

CodePudding user response:

Add name parameter inside your @Part annotation.

  @override
  @POST('/update/document')
  @MultiPart()
  Stream<double> uploadDocument(@Part(name:"id") int id,
                                @Part(name:"document") File document);

  • Related