Skip to content
Adrian Ehrsam edited this page Jan 12, 2021 · 2 revisions

Files

Initial Config

Make sure have have the file support enabled in your startup:

services.AddGenericBackend()
            .ConfigureMiddleware(m =>
            { // Set your options
            })
            .ConfigureOpenApiGeneration(o =>
            { // Set your options
            })
            .AddFileSupport()

File Upload

For uploading a file, name the parameters of your Stored Procedure with the following postfixes (at least two, content is required):

  • NAMEOFYOURFILEPARAM_Content
  • NAMEOFYOURFILEPARAM_ContentType
  • NAMEOFYOURFILEPARAM_FileName
  • NAMEOFYOURFILEPARAM_Length

This will make the Generic Backend treat the SP as File Upload SP and therefore requiring the HTTP Request to be a Multipart/form-data Request.

File Download

In your Settings File (appsettings.json or backendconfig.json) set the field "ResultType" to "File":

    "FileDownload": {
      "GET": {
        "SP": "spGetFile",
        "ResultType": "File"
      }
    }

The SP must return a field called Content and a field called ContentType. It may return a field called FileName as well.

Clone this wiki locally