Transloadit和PhoneGap [英] Transloadit and PhoneGap

查看:112
本文介绍了Transloadit和PhoneGap的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我检查了TransloadIt网站,它看起来像一个伟大的服务,但它的Jquery插件只与html表单输入...这不会真正工作与我的phonegap应用程序。
有没有办法将Phonegap相机捕获的图像上传到Transloadit?

I checked out TransloadIt website and it looked like a great service but its Jquery plugin works only with the html form input... this won't really work with my phonegap application. Is there a way to upload Phonegap camera captured image into Transloadit?

推荐答案

使用Transloadit工作的phonegap(cordova)应用程序



Transloadit接受POST数据,不需要通过表单发送。

Have a working phonegap (cordova) app with Transloadit

Transloadit accepts POST data and does not need to be sent via form.

这是他们在表单上使用的帖子数据:

Here is the post data they use on a form:

https://transloadit.com/docs/#the-minimal-integration (向下滚动)

<form id="upload-form" action="http://api2.transloadit.com/assemblies" enctype="multipart/form-data" method="POST">
  <input type="hidden" name="params" value="..." />
  <input type="file" name="my_file" />
  <input type="submit" value="Upload">
</form>

你所做的就是采用这些变量名,并在cordova文件传输插件中匹配它们: https://github.com/apache/cordova-plugin-file-transfer

What you do is take those variable names and just match them up in the the cordova file transfer plugin: https://github.com/apache/cordova-plugin-file-transfer

var params = {};
params.params = '[signed assembly goes here]';

var ft = new FileTransfer();
ft.upload(fileURL, 
  encodeURI("http://api2.transloadit.com/assemblies"),
  successCallback, failCallback, { params: params });

我所做的是通过我的服务器(ajax)根据需要获得一个签名的程序集,它可以安全地获取装配信息,以便您不会泄露您的私人信息,或者只是在未经您的同意的情况下打开您的帐户。

What I do is obtain a signed assembly via my server (ajax) on demand that has a timestamp on it to get the assembly info ready for the upload securely so you don't give out your private info or just open up your account to be posted into without your consent.

这是一个更多的涉及,因为我还有一个回调URL设置为transloadit一旦组件处理。然后它必须找到我注意到的上传的程序集,然后填充有关上传的元数据一旦完成。

It is a little more involved because I also have a callback URL setup for transloadit once the assembly is processed. It then has to find the assembly I noted for that upload and then populate the meta data about the upload once done.

当我发布这个,我最初假设这个是可能的,但自从建立它和它的工作很好。

At the time I posted this, I initially postulated this was possible, but since have built it and its working quite well.

这篇关于Transloadit和PhoneGap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆