Transloadit 在 c#.net 中无法获得 ASSEMBLY_COMPLETED 响应
Transloadit cannot get ASSEMBLY_COMPLETED response in c#.net
参考下面link
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);
}
在第一个回复中,您应该会看到 assembly_url
。您 can/should 每 X 秒轮询 URL 以获取更新。当程序集到达 ASSEMBLY_CANCELED
ASSEMBLY_COMPLETED
REQUEST_ABORTED
或设置 error
时,它就完成了。我不确定这个轮询的样板文件是否在 SDK 中实现,你必须检查一下。
不推荐使用阻塞程序集,因为它们需要保持连接打开,这更脆弱。
参考下面link
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);
}
在第一个回复中,您应该会看到 assembly_url
。您 can/should 每 X 秒轮询 URL 以获取更新。当程序集到达 ASSEMBLY_CANCELED
ASSEMBLY_COMPLETED
REQUEST_ABORTED
或设置 error
时,它就完成了。我不确定这个轮询的样板文件是否在 SDK 中实现,你必须检查一下。
不推荐使用阻塞程序集,因为它们需要保持连接打开,这更脆弱。