When I use a POSTMAN to do make a request, my API receives a IList<IFormFile>
.
How can I do the same request using Xamarin.Forms with REFIT?
You can use IEnumerable<StreamPart>
to upload a list of files:
public interface IApi
{
[Multipart]
[Post("/api/story/{id}/upload-images")]
Task UploadImages(int id, [AliasAs("files")] IEnumerable<StreamPart> streams);
}
Then you can call it:
var api = RestService.For<ISomeApi>("http://localhost:61468");
var files = new List<StreamPart>()
{
new StreamPart(fileStream, "photo.jpg", "image/jpeg"),
new StreamPart(fileStream2, "photo2.jpg", "image/jpeg")
};
await api.UploadImages(1, files);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With