Best approach to use a CDN service - google-app-engine

I am a mobile developer trying to do backend development. It is going more or less well but still having doubts about some subjects. Currently I want to add a Google app engine service to upload and resizing images on Google Storage. Now I am trying to define the best way to upload it because image is just a part of the object form data.
Option 1: I know I can use Javascript to send two different forms (one for the data to my own controller and the other one for image to the app engine service) pointing to different processing URIs and create a random string to use as a link between image and data (because after uploading successfully on Google Storage I need to write the URL on my object data.
Option 2: Upload everything in one form just with my service and store temporally the image locally and send it on background calling app engine from my controller.
Option 3: Storing everything like now and use a background task to send image to app engine and the replacing the image by the returned URI.
No one of this options convinces me, please if some of you faced this before, enlighten me.
Regards,

Related

How to make Ionic app work with an API written in Laravel but still works offline

I would like to ask how to create an ionic app that talks to Laravel API but still works offline when there's no connection.
Let's say i have to write a quiz mobile app in Ionic and it requests for Laravel API to retrieve the questions as well as store the scores in db.
I'm just starting to learn Ionic and i'm really confused right now on how to approach this.
What confuses me most are:
Does the Ionic source live inside the Laravel source code w/c serves the API?
If i want the Ionic app to be installable, should the Laravel source code be included as well during the compilation process?
Thanks in advance for any help.
Your php or in general server side code is completely independent from your ionic application. If you want your app to work offline you should think about something like fetching a high number of information initially and work with this data without making any additional requests.
However your ionic app does only contain the frontend. You could implement some logic for local storage, but if you want to keep information hidden from the user (e.g. solutions) you have to put that logic on a dedicated server.
In the few details you provided, I can say the Laravel code does not live inside the ionic app. The ionic app is separate from the backend API by Laravel. You are possibly trying for a ReST based architecture where you communicate with your Laravel Server with an API. You need to keep those codes separate.
However without any internet, you won't be able to access those APIs, so you will just be able to show some static data, or you could serve from a DB and show later. For how to use the sqlite db you can look here
In your backend you can have an API like
http://example.com/api/v1/questions/1/
Which will fetch a question with options and if you want the app to have the answer for offline storage you may have that as well. When a user answers, you may check whether you have internet access and send answer and verify if you do, else you may save the answer in your DB and sync when you do have access. You can fetch multiple questions so that a user may answer multiple questions in case he/she will not have internet access.
Hope it helps. :)

AngularJS, twitter api's rate limit and security

I'm developing an application in Cordova with AngularJS.. I'm trying to get a users feed and put the tweets with images in a slider/carousel. The carousel already works fine, but there comes the twitter api...
I was thinking about the twitter rate limit, if the app is downloaded for multiple users, the application won't be able to make more requests for a while. On the other hand, if I use the consumer key, secret and access token inside the application, it's probably that is easy for anyone to use them. So it can be insecure.
I was thinking about a little web service that takes twitter content every X minutes from twitter and save that content somewhere, so the application can access the content from the little web service. Is this plausible?
I've been messing around with this... but I don't see how... An embedded timeline wouldn't be a solution because I need a custom slider only for tweets with images..
Thanks for any help you can give me
My best regards
I think the best solution would be to make users authenticate with their twitter, then store the results you grab in some form of local storage. That way you don't have to share an api key between users, and when they make a call, it will store for x amount of time.

GWT uploading a photo

I m using Google App Engine (1.7) to store my entities on Datastore and GWT 2.4 to build the interface. Some entities have an image field, so a user when submits a new Entity (a "Product" for example) can upload her one image (of the product).
So my question is how I can create an upload field where the browsing window will appear when the user clicks in an element and after the upload process a thumbnail of that image will appear in this element!!
Any suggestions???
Check out GWT FileUpload component.
Take a look at this tutorial. I think it does exactly what you need:
GWT, Blobstore, the new high performance image serving API
"GWT Upload" is the best choice i have found. I have used it outside GAE (in my own application server) but i think it has GAE support as well. Basically to make it work you need to put the "GWT Upload control" onto your page, write the server side uploader (extending one provided) add some lines to web.xml, and that's it.

how to get the data in the datastore of App Engine by url

in Google App Engine,after using the makePersistent() to store the data in the datastore,i know how to get the data content by the key using getObjectById().
but now i wanna to get the data in the datastore by url. i think the url is created .
so the question is how the url can be created to get the data in the datastore
There is no built-in means to access the datastore through URLs. If you choose to, your application can implement URLs that return data from the datastore.
I invite you to take a look at titan-files. It's a powerful file-system abstraction on top of the DataStore and/or blob store. I'm using it for a commercial application and so far I've been very happy with it.

gwt and dynamic server processing. Do they belong together?

I am eager to build an application with Gwt and App Engine. I'm more familiar with App Engine: creating dynamic html pages with servlets and jsp's. I'm wondering however, if this type of application technology belongs with GWT?
The two examples I can foresee being a problem are login and database retrieval.
For user log-in, my current approach is simple: at the beginning of a servlet, check if the user object exists. If it does, show the page. If it doesn't, redirect to Google's login service. How does this model fit in with GWT? It seems to me that GWT compiles into static html/javascript/css files you place on your server. With this approach, it doesn't seem possible to do any server processing to check for a vlid user before serving the static page (because any user could just bypass the servlet and type the static page url directly).
The other example would be show data from the app engine datastore. If i wanted to create a table which each row being an entry from the data store, I would dynamiclly create the html in a servlet, and do my datastore access there etc, etc. It seems with GWT I would have to serve a container html page, then use ajax to load the database content after the fact?
Maybe GWT isn't right for my type of application, or maybe I'm just thing about web application development the wrong way. Some clarification would be appreciated.
In a over simplified sense, a typical GWT app will work like this:
User navigates to your web page. Their browser uses a static url(s) to download all the javascript, css, and images necessary to run your app.
From now on, every time a user presses a button or otherwise interacts with the page, data is retrieved via an AJAX call. So yes, they might download your app before logging in, but all your security sensitive data would only be returned via an ajax call, giving you the chance to validate their identity however you wish (cookie, user/pass, etc)
This is basically what you describe in your second example about loading data from the datastore. It sounds like you think this is bad for some reason, but you don't say why.

Resources