I'm uploading a file using multipart data form and I need to keep the file description of the uploaded file. I'm using the following code
FileDescription temp = new FileDescription();
var task = Request.Content.ReadAsMultipartAsync(streamProvider).ContinueWith<IEnumerable<FileDescription>>(t =>
{
if (t.IsFaulted || t.IsCanceled)
{
throw new HttpResponseException(HttpStatusCode.InternalServerError);
}
var fileInfo = streamProvider.FileData.Select(i =>
{
var info = new FileInfo(i.LocalFileName);
temp.AssociatedSchool = 1;
temp.FileName = info.Name;
temp.LocalFileName = i.LocalFileName;
temp.FileSize = info.Length / 1024;
temp.IsFileValid = true;
temp.NoOfRecords = 1;
temp.UploadedBy = 1;
return temp;
});
return fileInfo;
});
This code doesnt set the values to the temp
object. Can anyone tell me an alternate way to get the values? task.Result is always null. How can i get the values out of the thread?