Is it possible to override MultipartFormDataStreamProvider so that is doesn't save uploads to the file system?

后端 未结 2 931
予麋鹿
予麋鹿 2020-12-02 09:26

I have an ASP.Net Web API application that allows clients (html pages and iPhone apps) to upload images to. I am using an async upload task as described in this article.

2条回答
  •  时光说笑
    2020-12-02 10:07

    Since @KiranChalla posted their answer, a new abstract class MultipartFormDataRemoteStreamProvider was introduced in Fix 1760: Make MultipartFormDataStreamProvider easier to work with non-FileStreams. to make this easier.

    The summary of the class does a good job at explaining how to use it:

    A MultipartStreamProvider implementation suited for use with HTML file uploads for writing file content to a remote storage Stream. The stream provider looks at the Content-Disposition header field and determines an output remote Stream based on the presence of a filename parameter. If a filename parameter is present in the Content-Disposition header field, then the body part is written to a remote Stream provided by GetRemoteStream. Otherwise it is written to a MemoryStream.

提交回复
热议问题