We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
/// <summary> /// 上传文件FileUploadRequest /// </summary> public class FileUploadRequest : BaseRequest<FileUploadRequest> { public IFormFile? File { get; set; } public FileUploadRequest() { RuleFor(x => x.File).NotNull(); } } /// <summary> /// 上传文件测试 /// 请使用postman & apifox 测试 /// </summary> [QuickApi("fromfile", Verbs = Verb.POST)] public class FromFileApi : BaseQuickApi<FileUploadRequest, IResultResponse> { public override async Task<IResultResponse> ExecuteAsync(FileUploadRequest request) { //测试上传一个文本文件并读取内容 if (request.File != null) { using (var sr = new StreamReader(request.File.OpenReadStream())) { var content = await sr.ReadToEndAsync(); return Results.Ok(content).AsRsp(); } } return Results.BadRequest("no file").AsRsp(); } public override RouteHandlerBuilder HandlerBuilder(RouteHandlerBuilder builder) { builder.Accepts<FileUploadRequest>("multipart/form-data"); builder.WithOpenApi(operation => new(operation) { Summary = "上传文件测试", Description = "上传文件测试" }); return builder; } }
请注意 :如果需要支持文件上传 必须 重写HandlerBuilder 设置 : builder.Accepts("multipart/form-data");
The text was updated successfully, but these errors were encountered:
支持FileUpload功能 #7
67afcaf
No branches or pull requests
请注意 :如果需要支持文件上传 必须 重写HandlerBuilder 设置 : builder.Accepts("multipart/form-data");The text was updated successfully, but these errors were encountered: