I am trying to a pass a stream from a HttpPostedFileBase to a service method without saving to disk.
//Controller Action
[HttpPost]
public void Import()
{
if (Request.Files.Count == 0)
return new HttpStatusCodeResult(404);
var file = Request.Files[0];
_departmentAppService.Import(file.InputStream);
}
//Service Method
public string Import(Stream stream)
{
var excelFile = ExcelFile.Load(stream, LoadOptions.CsvDefault);
var worksheet = excelFile.Worksheets[0];
var jsonString = worksheet.ToJsonString();
return jsonString;
}
An error of "Property accessor 'ReadTimeout' on object 'System.Web.HttpInputStream' threw the following exception:'Timeouts are not supported on this stream.'" is thrown when the stream is passed to the method. Is there an idiomatic method of doing this?