[Route("upload")] //uploads to disc //Physically creates a file on the server and then exposes the stream representing the file for the developer to process further. Additionally, //MultipartFormDataStreamProvider will look for the filename in a Content-Disposition header. If this header is not //present, it will not write to the disk directly (will not use FileStream), but will instead expose the uploaded file as a //MemoryStream only. MultipartMemoryStreamProvider will always load the contents of the uploaded file into a MemoryStream. public async Task Post() { if (!Request.Content.IsMimeMultipartContent()) throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotAcceptable, "This request is not properly formatted")); var streamProvider = new CustomMultipartFormDataStreamProvider(Path.Combine(Assembly.GetExecutingAssembly().Location, @"..\..\..\uploads")); await Request.Content.ReadAsMultipartAsync(streamProvider); }
[Route("upload")] //uploads to disc //Physically creates a file on the server and then exposes the stream representing the file for the developer to process further. Additionally, //MultipartFormDataStreamProvider will look for the filename in a Content-Disposition header. If this header is not //present, it will not write to the disk directly (will not use FileStream), but will instead expose the uploaded file as a //MemoryStream only. MultipartMemoryStreamProvider will always load the contents of the uploaded file into a MemoryStream. public async Task Post() { if (!Request.Content.IsMimeMultipartContent()) { throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotAcceptable, "This request is not properly formatted")); } var streamProvider = new CustomMultipartFormDataStreamProvider(Path.Combine(Assembly.GetExecutingAssembly().Location, @"..\..\..\uploads")); await Request.Content.ReadAsMultipartAsync(streamProvider); }