Base solution for your next web application
Open Closed

Feature Request - Enhanced File Upload/Download Support in Dynamic API Controllers #12598


User avatar
0
Adrian created

Current state: ASP.NET Zero has an excellent Dynamic Web API Layer mechanism that automatically generates REST endpoints from Application Services. However, handling file operations (upload/download) requires additional configuration and manual controller creation. Proposed enhancement: Adding built-in DTO types for file operations that would be automatically recognized by the Dynamic Web API Layer:

  1. ApiFileInput - input type for file uploads, automatically bound from multipart/form-data. Contains properties: FileName (string), ContentType (string), Content (byte array).
  2. ApiFileOutput - output type for file downloads, automatically converted to a binary response with appropriate HTTP headers (Content-Type, Content-Disposition). Usage example: In an Application Service, we define an UploadDocument method that accepts ApiFileInput and returns Guid. The system automatically handles multipart/form-data and binds the file to the input object. For downloads, we define a DownloadDocument method that accepts Guid and returns ApiFileOutput. The system automatically sets response headers and returns the binary file. Benefits: • Eliminates the need to create separate controllers for file operations • Consistency with the existing Dynamic Web API pattern • Code simplification - one convention for all API operations • Automatic Swagger/OpenAPI documentation Reference implementation: We have a working implementation of this solution in our project. The system recognizes ApiFileInput type parameters and skips standard JSON binding for them, instead reading data from the multipart form. For returned values of type ApiFileOutput, the ResultAdapter creates a FileContentResult response with appropriate headers. We would be happy to share implementation details or help with integration into the existing Dynamic Web API Layer. Question: Are you considering adding such functionality in future versions of ASP.NET Zero? Is there currently a recommended way to handle file operations within Dynamic Web API without creating separate controllers?
Markdown is supported
Copy & paste or drag & drop images (max 30 MB per image)

1 Answer(s)
  • User Avatar
    0
    oguzhanagir created
    Support Team

    Hi @Adrian

    Thank you for the suggestion. We have created an issue for this feature request, and you can follow the progress there. If you have additional ideas or suggestions, feel free to share them through the same issue.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)