2

Its driving me nuts,somebody pls help me out here.This google cloud stuff is confusing me.I m little bit off here,something is missing in my understanding.I want to use cloud storage.Now I have a default Android Studio Project which has an android client,an app engine backend,consisting of entity,endpoint,library for client etc and A WEB CLIENT.While going through the google cloud storage doc, I found the following-

  1. Google APIs Client Libraries
  2. Google Cloud Storage Client Library
  3. Google Cloud Storage API
  4. Google Cloud Storage JSON API Client Library for Java

I m still not sure what each one does actually.I dont know how to implement cloud storage in my android client.

If I use cloud storage why do I need app engine backend app? I dont need API for my backend,right? I can directly consume my bucket using Google Cloud Storage JSON API as we do using Volley. Am I missing something here?

Is there any "hello world" tutorial on how to use cloud storage from android client/app or can anyone help ?

Tanvir
  • 1,642
  • 8
  • 32
  • 53
  • If you're 100% sure that you don't need any back-end logic, and never, **ever** will, see http://stackoverflow.com/questions/21953744/using-google-cloud-storage-json-api-in-android for direct Android <-> Google Cloud Storage operations. Usually in a successful app's lifetime some back-end logic **is** eventually required (e.g to deal with different versions of clients -- not all update in the same nanosecond:-), but if you're adamantly certain that your case is the exception, go for it!-) – Alex Martelli Mar 15 '15 at 01:03
  • thnk u very much,Why didnt u put it in Answer, so that I could accept. As far as I have understood the appengine,if I need to store data in NoSQL datastore,then I can make a backend with endpoint support which will in turn consume my Restful API. I mean, can I/should I consume the cloud storage rest API from within my backend endpoint, which itself is used to call my own rest API? Why do I need backend logic to deal with different versions of clients? Please explain, m having hard time to tidy up my understanding,I m missing something. Thnx – Tanvir Mar 15 '15 at 10:58
  • OK, reshaped my comment, plus answers to your latest questions, in the form of an answer. – Alex Martelli Mar 15 '15 at 15:18

1 Answers1

5

If you're 100% sure that you don't need any back-end logic, and never, ever will, see Using Google Cloud Storage JSON api in android for direct Android <-> Google Cloud Storage operations.

Usually, in the course of a successful app's lifetime, some logic on the back-end is eventually required (e.g to deal with different versions of clients -- not all update in the same nanosecond:-), so it's normally more prudent and future-proof to have the front-end go to an App Engine back-end that can apply whatever logic is required besides providing access to Cloud Storage.

At version 0.1 the amount of logic required may be very small (though usually at least some kind of authentication) but if the application is successful likely new versions will be required and the back-end will be able to evolve to deal with that.

Then in a comment you ask:

As far as I have understood the appengine, if I need to store data in NoSQL datastore, then I can make a backend with endpoint support which will in turn consume my Restful API.

A more common arrangement is to have the back-end supply a restful API for the front-end to consume; and, that's what Cloud Endpoints can do for you (though you could design and implement that restful API in many other different ways, if you'd rather).

I mean, can I/should I consume the cloud storage rest API from within my backend endpoint, which itself is used to call my own rest API?

One robust architecture is based on separation of concerns. Let the front-end running on Android concern itself essentially with the "human interface" part of your overall application -- presenting data clearly and usefully, interacting with the user.

The front-end can delegate just about every other concern to the back-end, including both storage and most aspects of app-specific logic concerned with what to store where, whether to allow access (of what kind -- read/write or read/only) to certain data depending on authentication of the user, and so on.

This delegation can take advantage of Cloud Endpoints, or, you could choose to design and implement it differently (e.g producing and consuming the app's REST API via different frameworks).

Why do I need backend logic to deal with different versions of clients?

You'll need that, for example, if and when a new version of the client wants to store and retrieve more data than older versions did -- for example, in some future version you may decide it can be useful to add GPS location data, or optionally multiple photos or an audio snippet, etc, etc, which were not used in previous versions. (It's hard to be specific of course without any idea as to what your app is all about, but in general there's always something that you didn't do in early versions and want to add to some future one:-).

In such cases, the back-end needs to know what bits and pieces of data, exactly, to expect from the client, and conversely which ones to serve back to the client -- and those crucial aspects will then depend on the client's version; and without back-end logic to mediate, smooth seamless transition between old and new clients won't be feasible, particularly during the transitional period when some clients have upgraded to the newer version but others are still stuck on the old one.

Community
  • 1
  • 1
Alex Martelli
  • 854,459
  • 170
  • 1,222
  • 1,395
  • Thnk u VERY MUCH,so kind of u,Pls correct me if I m wrong,after studying a lot I found that there r two ways we can reach the google cloud API:1.Sending HTTP request thru REST URI,e.g. Google Cloud Storage JSON API and,2.Using client library(like the ones generated from cloudendpoints to invoke my REST-API directly thru METHODS in client).There are google service specific CLIENT library,e.g.Google Cloud Storage JSON API Client Library for Java. Therefore, which is better to invoke any google cloud API- thru client lib OR REST URI? – Tanvir Mar 16 '15 at 05:02
  • @Tanvir, I personally tend to like the client libraries, which "dress up" the REST API into more specific-language-idiomatic garb, making for easier future maintenance. But, that's a matter of taste! -) – Alex Martelli Mar 16 '15 at 05:09
  • "Separation of concerns" sounds like "MVC pattern" to me,(model=entity,view=activity/fragment,controller=endpoints),I think its really safer way to program.The point is, endpoint generates library for each method in class.It makes consumable REST API from those methods.Is it wise to use another REST URI (e.g. google cloud json API) in that to invoke another google resource? OR should I use the client library,e.g.Google Cloud Storage JSON API Client Library for Java, which can directly call the REST URI fro cloud storage or any resource. Correct me if I m wrong anyway here. So many thanx again – Tanvir Mar 16 '15 at 05:14
  • @Tanvir, in your shoes, I'd stick to using the endpoints in the Android front-end, and relegate other concerns to the GAE back-end. MVC is **one** example of "separation of concerns" but far from the whole picture (it decently structures the architecture to deal with user interaction -- but has nothing to say e.g about separating storage access from app-specific logic, for example). But, that's a much broader and higher-abstraction Q wrt what you're asking here! – Alex Martelli Mar 16 '15 at 05:18
  • Then, in this case u suggest that I use google api client library in the front end/android app for accessing google cloud.Then again,as u explained earlier,wont it affect any "new version of client". By the way, can I use any google client library in cloud endpoint class,if I want. – Tanvir Mar 16 '15 at 05:28
  • @Tanvir, no, I suggest the Android front end interact only with the GAE back end, and let the latter worry about orchestrating things. And sure, you can use client libraries to any Google API on the GAE side of things. – Alex Martelli Mar 16 '15 at 05:39
  • Thnk u soooooooooo much ... gracious – Tanvir Mar 16 '15 at 06:09