Question
Usman Bajwa on Fri, 28 Oct 2016 05:11:57
I want uploading file on media services. When I upload file it gives exception after some time. here is the exception
Remote Server returns 500 Internal Server Error
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at Microsoft.WindowsAzure.MediaServices.Client.AssetFileData.Upload(String path)
at OnDemandEncoding.Models.Azure.UploadFile(String filePath) in C:\Users\Usman Bajwa\Desktop\Cloud Tech\OnDemandEncoding\OnDemandEncoding\Models\Azure.cs:line 49
Here is my uploading code: I am geeting exception at assetFile.Upload(filePath);
public static string UploadFile(string filePath){
string assetId = null;
try
{
CloudMediaContext _context = GetContext();
string assetName = Path.GetFileNameWithoutExtension(filePath);
IAsset Asset = _context.Assets.Create(assetName, AssetCreationOptions.None);
Console.Error.Write("Asset Created");
IAssetFile assetFile = Asset.AssetFiles.Create(Path.GetFileName(filePath));
Console.Error.Write(assetFile.Name);
var policy = _context.AccessPolicies.Create(
assetName,
TimeSpan.FromDays(20),
AccessPermissions.Write | AccessPermissions.List);
ILocator locator = _context.Locators.CreateLocator(LocatorType.Sas, Asset, policy);
Console.Error.Write(assetFile.Name);
Console.Error.Write("Uploading File");
assetFile.Upload(filePath); // Getting Exception at this line
locator.Delete();
policy.Delete();
return assetId = assetFile.Asset.Id;
}
catch (Exception e)
{
return e.Message;
}
}
Replies
Wendy Zang on Fri, 28 Oct 2016 07:37:20
Hi Usman Bajwa,
Thank you for posting here.
Since your problem is more related to Azure Media Service, I will move it to Azure Media Services Forum for support.
The Visual C# forum discuss and ask questions about the C# programming language, IDE, libraries, samples, and tools.
If you have some grammar or code errors, please feel free to contact us. We will try our best to give you a solution.
Thanks for your understanding and cooperation.
Best Regards,
Wendy