I am developing an Ionic hybrid app and one of the features is taking/choosing a picture and uploading it to the server. I found plenty of examples of how to use $cordovaFileTransfer plugin. The problem is that my backend is in Django and I don't really understand how to process the upload request from the cordova plugin.
Any help or a small example would be appreciated. Thank you.
$cordovaFileTransfer is only the Ionic wrapper for the cordova file transfer plugin. The documentation says:
The FileTransfer object provides a way to upload files using an HTTP multi-part POST or PUT request, and to download files as well.
Since these are simple http POST requests, you don't need nothing special but only the Django file uploads documentation that contains a well documented example.
Related
I'm new to Angular and Ionic. I'm trying to create a page where a user can upload the file from google drive to the server. He has to do it by logging into Google drive then choose the file from google drive and upload into the server. I don't have any idea of how to start and where to start. If you can guide me or give me an example, it would be helpful.
Thank you.
If you are just starting, I would recommend to start reading first about the documents regarding the Drive API and Ionic Development/ AngularJS. This would help you understand how Drive API works and what are the available functions on the API you use (REST, iOS, Android). These document can help you understand the flow and some code samples that will explain how the function will work. You can also find handling of errors, best practices and performance tips to help you improve your app.
Here are some github repo that can help you with the implementation:
Ionic
AngularJS
Hope this helps.
i'm developping an app with the ionic framework and a jee + postgresql backend.
I'm actually doubting about the HTTP Requests :
Should i use only jsonp? Or add an Access-Control-Allow-Origin * in my HTTP headers ?
Of course, both of these solutions are working, the second solution seems unsecure to me but i'm not use to mobile requests (without domain-based call/endpoint) so i don't really know what to choose ... i might also miss some other way to do the job ....
Do somebody know how to properly build this kind of communication ?
Thanks you !
If you want to be very flexible and very secure, you might want to implement a JSON Web Token solution. The server issues json web tokens to your users. You can define who gets a token. Then the token must be attached to every request from ionic to your server. The server determines what data to return, if the user is authorized.
For JEE there is this package. For ionic the auth0 repositories are a good study start. You can find many examples online. I think that is the most elaborate solution available, despite might not be easiest to implement.
I'd like to build a new single page app using Rails 4 and Angular and Capistrano for deployment process.
I want all the front end to be a static app on Amazon S3, but I'm openminded for other suggestions.
What's important to me is a fast developing process with the ability to scale up easily.
I was wondering what is the best structure I should use:
keep all assets in app/assets and set Bower path to vender directory.
that way i can use rails precompile methods and enjoying Rails html tags for index.html, but i'm sure it will be easy to upload it to S3 and keep it separated.
keep all assets including Bower components in public/app directory, which will keep it as a complete separate application, but then i need to use Grunt or any other service for precompiling assets.
any other idea?
From my experience, I found this approach to work really well:
API app (Rails/Sinatra/Grape/Node/whatever) serves only JSON APIs. Deploys to a server, say api.yourapp.com. Serves Access-Control headers.
Static web app: started by generating with yeoman an AngularJS, Gulp, Bower app. Deploys using gulp aws deploy module to S3.
There's no real reason to have both views and apis in the same app or built with the same technology (as in Rails).
Now there are issues:
S3 doesn't support nicely Angular's HTML5 mode URLs. So pure S3 website isn't an option.
Facebook doesn't read OpenGraph tags that are not in the source of the page.
Couldn't figure out the state of Google/SEO and Angular apps. I didn't see the content in the search results.
So as a solution I introduced another web server app. Can be based on anything - pure rack, node etc. I chose rack.
Solutions to the problems:
Web server app was hosted on www.yourapp.com and proxied (and cached) requests to S3. It supported all URLs (html5Mode) - just proxied to index.html.
OpenGraph meta tags - the API had an endpoint that gets a URL or ID of an object and returns meta tags information. Web server issues a request to API once per URL (caches the response) and injects it in the served index.html.
SEO - as a middleware, used prerender for rack that rendered pages on the server.
As a bonus -
Most apps today have a landing page/marketing site and the actual app. Sometimes it's better to maintain these separately. The web sever knows according to a cookie which app to present on www.yourapp.com - actual app or marketing site. On sign in - set a cookie on client side and voila.
First, I think there's a bit of a confusion here, let me try to clear it up.
There are a couple of ways for achieving this
Pure client -> API
When you have a static application, there's no need to go through the Rails asset pipeline, there are far better ways to manage assets when you are using the tooling for client side applications.
For example, your client application will be an Angular application and you will manage assets with a combination of bower (dependencies) and grunt (build and distribution).
There's no point of deploying to S3 with Capistrano, if it's a pure static application, you can use aws CLI in order to just upload your content.
I'd go through a CDN as well. Something like Fastly works really well over Amazon S3.
I have a Rake task that uploads to S3 and then clears the cache on Fastly (if I need to).
As for your Rails application, it would act as an API, it should not have any assets
Combined
If you have a combined application, some of the actions are served by the server (Rails) and just invokes some client side code (Angular).
If this is the case, I would go through Rails asset pipeline and just keep everything as Rails best practice with compilation pre-deploy etc...
It's one of those questions where "it depends" is the answer really, it all depends on what you want to achieve.
When I have a client application, I try to have a pure client and have the server only as an API, with no assets at all, this way, I separate the concerns.
EDIT 9/9/15
I'd have to say that as long as you can, I'd keep the apps separate.
It's not always possible, especially with more complex apps.
Most apps I have seen in the recent months have kept the client side and the server side code separate, I have seen less use of rails and more use of rails-api because of that (some even ditched rails completely for thinner solutions).
Right now, I am working on a web project(HTML + CSS + JavaScript) using PhoneGap to release APP to android device.
There is a page contains attachment. When user click the attachment link, the user can download it. While the attachment can be very large, the user would cancel the download if he like.
Our program sends HTTP request to the backend to get the attachment.
I just wonder how can I cancel a ongoing download?
Can it be done in front end using Javascript or any PhoneGap API?
Or it can be done in the backend?
I know when you download file from website using chrome, chrome its self can cancel the ongoing download, how chrome does that?
Any information will be appreciate. Thanks a lot.
As a matter of fact, when you want to download file, you should use PhoneGap API class FileTransfer.FileTransfer contains abort function can cancel the ongoing download.
http://docs.phonegap.com/en/1.0.0/phonegap_file_file.md.html#FileTransfer
This is my first time with google apis and I am having trouble implementing the email settings api in eclipse .Please tell me exactly which jar files are to be included and how ? I am getting GmailSettingsService class not found error.Please Help
Thank you
From here:
Didn't you ever want some kind of tool to create new Google Data projects in seconds? Google Data Java Client Eclipse
Plug-in is now available for use.
Using this plug-in you can create a new Java project to interact with
any Google Data API of your choice. Now, you don't need to worry about
setting up the dependencies for your Google Data project. This plug-in
handles all the dependencies and also provides you with an option to
download the external dependencies. It also creates a boiler plate
code to interact with the API that you are interested in. This will
give a quick start to all the newbies.