简体   繁体   English

向 JobInputHttp 提交编码 URL 时,为什么 Azure 媒体服务 v3 作业失败?

[英]Why does Azure Media Services v3 job fail when submitting an encoded URL to JobInputHttp?

When submitting urls to the JobInputHttp class to use an uploaded video as a media source, the job fails if the url is encoded because the file name has spaces?向 JobInputHttp 类提交 url 以使用上传的视频作为媒体源时,如果 url 被编码,因为文件名有空格,作业会失败?

For encoding I am just using encodeURI() to replace the spaces character with %20 using JavaScript before sending it to the web server.对于编码,我只是使用 encodeURI() 在将空格字符发送到 Web 服务器之前使用 JavaScript 用 %20 替换空格字符。

File is uploaded to blob storage from client side.文件从客户端上传到 blob 存储。 I am able to view the video from azure portal so it is being uploaded correctly.我可以从 azure 门户查看视频,因此可以正确上传。 After the video is uploaded a stream attempts to be created by sending the encoded url and filename of the uploaded file to the backend before submitting to Azure Media Services (AZM).视频上传后,在提交到 Azure 媒体服务 (AZM) 之前,会尝试通过将上传文件的编码 URL 和文件名发送到后端来创建流。

Test Cases:测试用例:

  • Filename without spaces and meets naming conventions - Passes and viewable from AZM asset文件名没有空格并符合命名约定 - 通过并从 AZM 资产中查看
  • Filename contains spaces - Unsure if spaces meeting AZM Asset naming conventions文件名包含空格 - 不确定空格是否符合AZM 资产命名约定
    • Returns 500 Error if not encoded如果未编码,则返回 500 错误
    • Job fails in azure portal when encoded with error "While trying to download the input files, the files were not accessible, please check the availability of the source", screenshot below.当编码错误“尝试下载输入文件时,文件无法访问,请检查源的可用性”时,作业在 azure 门户中失败,屏幕截图如下。

Failed Job Screenshot失败的作业截图

Current Code:当前代码:

        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;
    }

Example using Azure Media Services 使用 Azure 媒体服务的示例

Example using JobInputHttp Class 使用 JobInputHttp 类的示例

Answer: The encodeURI() function was also encoding special characters within the Shared Access Signature (SAS) token submitted in the url.答案:encodeURI() 函数还在 url 中提交的共享访问签名 (SAS)令牌中编码特殊字符。

I tested the submission using <string>.replaceAll(' ', '%20') and was able to get a passing AZM job.我使用<string>.replaceAll(' ', '%20')测试了提交<string>.replaceAll(' ', '%20')并且能够获得通过的 AZM 作业。 I ran the full URL through encodeURI() and compared the SAS Tokens and realized it changed %253D to %25253D based on standard HTML encoding .我跑通过是encodeURI()的完整URL,并比较了SAS令牌和实现它改变%253D%25253D基于标准的HTML编码

Testing code from MDN来自MDN 的测试代码

const encoded = encodeURI("%253D");
console.log('Encoded: ', encoded);
// expected output: "%25253D"

try {
  console.log('Decoded', decodeURI(encoded));
  // expected output: "%253D"
} catch (e) { // catches a malformed URI
  console.error(e);
}

// output
//"Encoded: " "%25253D"
//"Decoded" "%253D"

Because the URL was not being decoded before being submitted it was not able to locate the video source.因为 URL 在提交之前没有被解码,所以无法定位视频源。

I guess I just needed to ask the question to get the answer.我想我只需要问这个问题就可以得到答案。 Real-life rubber ducky debugging :).真实的橡皮鸭调试:)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Azure Media Services v3 CreateEvent挂起 - Azure Media Services v3 CreateEvent Hangs Azure 媒体服务、带有 V3 api 和 ODataQuery 的 GetLocators - Azure Media Services, GetLocators with V3 api and ODataQuery 在 Azure 媒体服务 v3 中使用 CopyAudio 转码 mxf 视频文件 - Transcoding mxf video file with CopyAudio in Azure Media Services v3 Azure 媒体服务 (v3) blob 存储、资产和定位器备份 - Azure Media Services (v3) blob storage, assets, and locators backup Azure 媒体服务 v3 Assets.ListContainerSasAsync 返回 ApiErrorException - Azure Media Services v3 Assets.ListContainerSasAsync returns ApiErrorException Azure 下载链接的媒体服务 v3 共享访问策略 - Azure Media Services v3 shared access policy for download link 如何使用 Azure 媒体服务 v3 从 .mp3(或其他纯音频)文件编码的 .mp4 生成空的或空白的视频层? - How to generate empty or blank videolayer to .mp4 which is encoded from .mp3 (or other audio-only) files using Azure Media Services v3? 在 Azure 媒体服务 V3 中将资产下载/发布为单个视频文件 - Download/Publish an Asset as a single video file in Azure Media Services V3 无法在Azure Media Services中发布编码的资产 - Cannot Publish Encoded Asset in Azure Media Services Azure 媒体服务 V3 音频分析器脚本 10 分钟限制 - Azure Media Services V3 audio analyzer transcript 10 minute limit
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM