[英]How to upload files using NET CORE and Refit
You can use IEnumerable<StreamPart>
to upload a list of files: 您可以使用
IEnumerable<StreamPart>
上载文件列表:
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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.