0

通过以下链接的参考

https://github.com/nkranitz/transloadit-csharp-sdk 我使用 transloadit 进行视频转换并将其保存在 C# 中的 s3 中。我能够上传视频和图像,并且能够得到空结果的响应。我的回复是“ok”:“ASSEMBLY_EXECUTING”,消息和结果标签是空的。因此,一旦像 ASSEMBLY_COMPLETED 一样执行程序集,我就没有得到最终响应。所以,我看到有一些属性 assembly.setblocking = true .. 但在 C# 中该属性不可用。那么如何获得最终响应或如何在 c#.net 中使用阻塞属性

请帮我解决这个问题。

提前致谢。

下面是代码片段

ITransloadit transloadit = new Transloadit.Transloadit("APIKEY", "Secret");

        //Create assembly builder to build up the assembly
        IAssemblyBuilder assembly = new AssemblyBuilder();
        //Add a file to be uploaded (with autogenerated key)
        assembly.AddFile(@"filepath"); 

       //Define the step, you can define more in the same assembly
        IStep step = new Step();
        step.SetOption("robot", "/image/resize");
        step.SetOption("width", 75);
        step.SetOption("height", 75);
        step.SetOption("resize_strategy", "pad");
        step.SetOption("background", "#000000");

        //Add the step to the assembly
        assembly.AddStep("thumb", step);

        //Set notification URL
        assembly.SetNotifyURL("url");

        //Set the expiration date time of the request for the assembly
        //Assembly will be expired in 120 minutes from now
        assembly.SetAuthExpires(DateTime.Now.AddMinutes(120));
        //Invoke assembly, and wait for the result
        TransloaditResponse response = transloadit.InvokeAssembly(assembly);

        if (response.Success)
        {
          //  LoggerFactory.GetLogger().LogInfo(Type.GetType("TestConsole.Program"), "Assembly {0} result", response.Data);
        }
4

1 回答 1

0

在第一个响应中,您应该看到一个assembly_url. 您可以/应该每X秒轮询一次该 URL以获取更新。当程序集到达ASSEMBLY_CANCELED ASSEMBLY_COMPLETED REQUEST_ABORTEDerror设置时,它就完成了。我不确定这个轮询的样板是否在 SDK 中实现,你必须检查一下。

不建议使用阻塞组件,因为它们需要保持连接打开,这更脆弱。

于 2015-02-26T14:49:02.683 回答