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?
I know Transloadit, but not Phonegap. Can you do a multipart form post? Transload can accept that without jQuery. If you can use XHR, then this might be a good example for you https://github.com/tim-kos/transloadit_xhr/blob/master/transloadit_xhr.js
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 (scroll down a bit)
<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>
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 });
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.
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.
来源:https://stackoverflow.com/questions/19434968/transloadit-and-phonegap