【发布时间】:2020-10-15 21:44:33
【问题描述】:
向 JobInputHttp 类提交 url 以使用上传的视频作为媒体源时,如果由于文件名有空格而对 url 进行了编码,则作业会失败?
对于编码,我只是使用 encodeURI() 在将空格字符发送到 Web 服务器之前使用 JavaScript 将空格字符替换为 %20。
文件从客户端上传到 Blob 存储。我能够从 azure 门户查看视频,因此可以正确上传。视频上传后,将尝试通过将上传文件的编码 url 和文件名发送到后端来创建流,然后再提交给 Azure 媒体服务 (AZM)。
测试用例:
- 文件名不带空格并符合命名约定 - 可以通过 AZM 资产查看
- 文件名包含空格 - 不确定空格是否满足 AZM Asset naming conventions
- 如果未编码则返回 500 错误
- 当编码错误“尝试下载输入文件时,文件无法访问,请检查源的可用性”时,Azure 门户中的作业失败,屏幕截图如下。
当前代码:
private async Task<Job> SubmitJobAsync(IAzureMediaServicesClient client,
string resourceGroup,
string accountName,
string transformName,
string outputAssetName,
string jobName,
string url)
{
// This example shows how to encode from any HTTPs source URL - a new feature of the v3 API.
// Change the URL to any accessible HTTPs URL or SAS URL from Azure.
JobInputHttp jobInput =
new JobInputHttp(files: new[] { url });
JobOutput[] jobOutputs =
{
new JobOutputAsset(outputAssetName),
};
// In this example, we are assuming that the job name is unique.
//
// If you already have a job with the desired name, use the Jobs.Get method
// to get the existing job. In Media Services v3, the Get method on entities returns null
// if the entity doesn't exist (a case-insensitive check on the name).
Job job = await client.Jobs.CreateAsync(
resourceGroup,
accountName,
transformName,
jobName,
new Job
{
Input = jobInput,
Outputs = jobOutputs,
});
return job;
}
【问题讨论】:
标签: c# azure azure-media-services