I am using the method of the Interface
System.Threading.Tasks.Task<object> UploadFileAsync(string fileName, Stream fileStream, CloudUploadFileProgressChanged uploadProgressChanged, CancellationToken cancellationToken)
Task<object> which is the reurn type contains each file uploaded but how do I get this as a list which I can then use. This file list is different from what is uploaded bcos the uploaded files have the server side url link where as client files have c:\url
My code is as below
public Task<object> UploadFileAsync(string fileName, System.IO.Stream fileStream, CloudUploadFileProgressChanged uploadProgressChanged, CancellationToken cancellationToken)
{
Func<object> f = () =>
{
lock (_object)
{
FileSize = fileStream.Length;
if (uploadProgressChanged != null)
{
UploadProgressChanged = uploadProgressChanged;
UploadProgressChanged(FileSize / 10);
}
if (cancellationToken != CancellationToken.None && cancellationToken.IsCancellationRequested)
{
return null;
}
HttpResponseMessage fileResult;
CustomFileResult customFileResult;
try
{
fileResult = UploadFile(fileName, fileStream, cancellationToken).Result;
if (fileResult.IsSuccessStatusCode)
{
var response = fileResult.Content.ReadAsStringAsync();
customFileResult = JsonConvert.DeserializeObject<CustomFileResult>(response.Result);
}
else
{
var message = string.Format("Status code {0}, Reason {1}", fileResult.StatusCode,
fileResult.ReasonPhrase);
throw new ApplicationException(message);
}
}
catch (System.Exception)
{
throw;
}
if (UploadProgressChanged != null)
{
UploadProgressChanged(FileSize);
}
return customFileResult;
}
};
fileStream.Position = 0;
return Task.Factory.StartNew(f, cancellationToken);
}
public class CustomFileResult
{
public IEnumerable<string> FileNames { get; set; }
public string Description { get; set; }
public DateTime CreatedTimestamp { get; set; }
public DateTime UpdatedTimestamp { get; set; }
public string DownloadLink { get; set; }
public IEnumerable<string> ContentTypes { get; set; }
public IEnumerable<string> Names { get; set; }
public IEnumerable<string> Sizes { get; set; }
}
Can you provide an example where I can get hold of the result of the upload and populate the client side with the server images which are uploaded which in my case is the CustomFileResult and the property is DownloadLink.