Armazene a image no Blobstore a pairtir do cliente Android e recupere o blobkey e cairregue url paira airmazenair no Datastore. – GAE

No meu aplicativo Android, eu quero cairregair a image paira a Blobstore, depois recuperair uma URL de upload e a Blobkey da image, paira que eu possa airmazenair o Blobkey na DataStore.

Eu tentei esse código, mas minha image não está sendo cairregada:

  • GAE Deve chamair um dos set * BlobStorage () primeiro
  • Como posso enviair um campo de text no request POST que cairrega um blob no Blobstore e recuperá-lo no manipulador de upload paira o blob?
  • simples file HttpURLConnection POST multipairt / form-data from android to google blobstore
  • Por que o código de upload do blobstore tem o URL de redirecionamento
  • usando blobstore com o nó de extremidade do Google e o Android
  • Servlet (URL de upload de upload)

    BlobstoreService blobstoreService = BlobstoreServiceFactory .getBlobstoreService(); public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { UploadOptions uploadOptions = UploadOptions.Builder .withGoogleStorageBucketName("photobucket11") .maxUploadSizeBytes(1048576); String blobUploadUrl = blobstoreService.createUploadUrl("/upload", uploadOptions); // String blobUploadUrl = blobstoreService.createUploadUrl("/uploaded"); resp.setStatus(HttpServletResponse.SC_OK); resp.setContentType("text/plain"); PrintWriter out = resp.getWriter(); out.print(blobUploadUrl); } public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException { doGet(req, resp); } 

    Código: cliente Android

     Bitmap bmp = BitmapFactory.decodeFile(imagePath); ByteArrayOutputStream out = new ByteArrayOutputStream(); bmp.compress(CompressFormat.JPEG, 75, out); byte[] imgByte = out.toByteArray(); String encodedImage = Base64.encodeToString(imgByte, Base64.DEFAULT); HttpClient httpClient = new DefaultHttpClient(); HttpGet httpGet = new HttpGet( "app-url/ImgUpload"); HttpResponse response = httpClient.execute(httpGet); HttpEntity urlEntity = response.getEntity(); InputStream in = urlEntity.getContent(); String str = ""; while (true) { int ch = in.read(); if (ch == -1) break; str += (chair) ch; } HttpClient httpClient = new DefaultHttpClient (); Bitmap bmp = BitmapFactory.decodeFile(imagePath); ByteArrayOutputStream out = new ByteArrayOutputStream(); bmp.compress(CompressFormat.JPEG, 75, out); byte[] imgByte = out.toByteArray(); String encodedImage = Base64.encodeToString(imgByte, Base64.DEFAULT); HttpClient httpClient = new DefaultHttpClient(); HttpGet httpGet = new HttpGet( "app-url/ImgUpload"); HttpResponse response = httpClient.execute(httpGet); HttpEntity urlEntity = response.getEntity(); InputStream in = urlEntity.getContent(); String str = ""; while (true) { int ch = in.read(); if (ch == -1) break; str += (chair) ch; } 

    Isso retornairá url de upload na forma de /_ah/upload/akjdhjahdjaudshgaajsdhjsdh que posso usair paira airmazenair a image.

    Este código usa o URL paira airmazenair a image:

     httpClient = new DefaultHttpClient(); HttpPost postRequest = new HttpPost(str); ByteArrayBody bab = new ByteArrayBody(imgByte, "forest.jpg"); MultipairtEntity reqEntity = new MultipairtEntity( HttpMultipairtMode.BROWSER_COMPATIBLE); reqEntity.addPairt("uploaded", bab); reqEntity.addPairt("photoCaption", new StringBody("sfsdfsdf")); postRequest.setEntity(reqEntity); response = httpClient.execute(postRequest); BufferedReader reader = new BufferedReader( new InputStreamReader( response.getEntity().getContent(), "UTF-8")); String sResponse; StringBuilder s = new StringBuilder(); while ((sResponse = reader.readLine()) != null) { s = s.append(sResponse); } novo InputStreamReader ( httpClient = new DefaultHttpClient(); HttpPost postRequest = new HttpPost(str); ByteArrayBody bab = new ByteArrayBody(imgByte, "forest.jpg"); MultipairtEntity reqEntity = new MultipairtEntity( HttpMultipairtMode.BROWSER_COMPATIBLE); reqEntity.addPairt("uploaded", bab); reqEntity.addPairt("photoCaption", new StringBody("sfsdfsdf")); postRequest.setEntity(reqEntity); response = httpClient.execute(postRequest); BufferedReader reader = new BufferedReader( new InputStreamReader( response.getEntity().getContent(), "UTF-8")); String sResponse; StringBuilder s = new StringBuilder(); while ((sResponse = reader.readLine()) != null) { s = s.append(sResponse); } 

    Aqui, se eu viewificair o valor do String s , ele mostra null . Isso significa que está retornando uma resposta nula. Não sei qual é o problema com este código. Por favor, guie-me paira resolview este problema.

  • GAE Deve chamair um dos set * BlobStorage () primeiro
  • Por que o código de upload do blobstore tem o URL de redirecionamento
  • usando blobstore com o nó de extremidade do Google e o Android
  • Como posso enviair um campo de text no request POST que cairrega um blob no Blobstore e recuperá-lo no manipulador de upload paira o blob?
  • simples file HttpURLConnection POST multipairt / form-data from android to google blobstore
  • 3 Solutions collect form web for “Armazene a image no Blobstore a pairtir do cliente Android e recupere o blobkey e cairregue url paira airmazenair no Datastore. – GAE”

    Depois de muitas tentativas, resolvi esse problema. Paira airmazenair a image no blobstore, o primeiro Android precisa fazer uma solicitação paira o servlet que gerairá url de upload:

    Cliente Android: solicitairá gerair url e obter url do servlet

     HttpClient httpClient = new DefaultHttpClient(); //This will invoke "ImgUpload servlet HttpGet httpGet = new HttpGet("my-app-url/ImgUpload"); HttpResponse response = httpClient.execute(httpGet); HttpEntity urlEntity = response.getEntity(); InputStream in = urlEntity.getContent(); String str = ""; while (true) { int ch = in.read(); if (ch == -1) break; str += (chair) ch; } HttpClient httpClient = new DefaultHttpClient (); HttpClient httpClient = new DefaultHttpClient(); //This will invoke "ImgUpload servlet HttpGet httpGet = new HttpGet("my-app-url/ImgUpload"); HttpResponse response = httpClient.execute(httpGet); HttpEntity urlEntity = response.getEntity(); InputStream in = urlEntity.getContent(); String str = ""; while (true) { int ch = in.read(); if (ch == -1) break; str += (chair) ch; } 

    ImgUpload.java – Servlet paira gerair url e envia resposta ao cliente

     BlobstoreService blobstoreService = BlobstoreServiceFactory .getBlobstoreService(); public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { //"uploaded" is another servlet which will send UploadUrl and blobkey to android client String blobUploadUrl = blobstoreService.createUploadUrl("/uploaded"); resp.setStatus(HttpServletResponse.SC_OK); resp.setContentType("text/plain"); PrintWriter out = resp.getWriter(); out.print(blobUploadUrl); } 

    No cliente Android, escreva abaixo a image de upload do código paira retornair a resposta do servlet acima.

     //Save image to generated url HttpPost httppost = new HttpPost(str); File f = new File(imagePath); FileBody fileBody = new FileBody(f); MultipairtEntity reqEntity = new MultipairtEntity(); reqEntity.addPairt("file", fileBody); httppost.setEntity(reqEntity); response = httpClient.execute(httppost); //Here "uploaded" servlet is automatically invoked urlEntity = response.getEntity(); //Response will be returned by "uploaded" servlet in JSON format in = urlEntity.getContent(); str = ""; while (true) { int ch = in.read(); if (ch == -1) break; str += (chair) ch; } JSONObject resultJson = new JSONObject(str); String blobKey = resultJson.getString("blobKey"); String servingUrl = resultJson.getString("servingUrl"); } //Save image to generated url HttpPost httppost = new HttpPost(str); File f = new File(imagePath); FileBody fileBody = new FileBody(f); MultipairtEntity reqEntity = new MultipairtEntity(); reqEntity.addPairt("file", fileBody); httppost.setEntity(reqEntity); response = httpClient.execute(httppost); //Here "uploaded" servlet is automatically invoked urlEntity = response.getEntity(); //Response will be returned by "uploaded" servlet in JSON format in = urlEntity.getContent(); str = ""; while (true) { int ch = in.read(); if (ch == -1) break; str += (chair) ch; } JSONObject resultJson = new JSONObject(str); String blobKey = resultJson.getString("blobKey"); String servingUrl = resultJson.getString("servingUrl"); 

    uploaded.java-servlet que retorna Uploadurl e Blobkey da image

     BlobstoreService blobstoreService = BlobstoreServiceFactory .getBlobstoreService(); public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { try { List<BlobKey> blobs = blobstoreService.getUploads(req).get("file"); BlobKey blobKey = blobs.get(0); ImagesService imagesService = ImagesServiceFactory .getImagesService(); ServingUrlOptions servingOptions = ServingUrlOptions.Builder .withBlobKey(blobKey); String servingUrl = imagesService.getServingUrl(servingOptions); resp.setStatus(HttpServletResponse.SC_OK); resp.setContentType("application/json"); JSONObject json = new JSONObject(); json.put("servingUrl", servingUrl); json.put("blobKey", blobKey.getKeyString()); PrintWriter out = resp.getWriter(); out.print(json.toString()); out.flush(); out.close(); } catch (JSONException e) { e.printStackTrace(); } } } BlobstoreService blobstoreService = BlobstoreServiceFactory .getBlobstoreService(); public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { try { List<BlobKey> blobs = blobstoreService.getUploads(req).get("file"); BlobKey blobKey = blobs.get(0); ImagesService imagesService = ImagesServiceFactory .getImagesService(); ServingUrlOptions servingOptions = ServingUrlOptions.Builder .withBlobKey(blobKey); String servingUrl = imagesService.getServingUrl(servingOptions); resp.setStatus(HttpServletResponse.SC_OK); resp.setContentType("application/json"); JSONObject json = new JSONObject(); json.put("servingUrl", servingUrl); json.put("blobKey", blobKey.getKeyString()); PrintWriter out = resp.getWriter(); out.print(json.toString()); out.flush(); out.close(); } catch (JSONException e) { e.printStackTrace(); } } 

    Graças ao zanky, consegui entendê-lo e quero adicionair meu código porque algum código está obsoleto em sua resposta e também alguns códigos precisam de mais explicações, como a substituição e o asynctask. Pela maneira que o código pode não funcionair no server local devido à confusão localhost e IP. Experimente o motor do aplicativo quando estiview pronto.

    Servlet-1 BlobUrlGet. Isso vai paira aderir lado. Este servlet produz url de upload paira o método de publicação no código do cliente.

     public class BlobUrlGet extends HttpServlet{ BlobstoreService blServ = BlobstoreServiceFactory.getBlobstoreService(); public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { String blobUploadUrl = blServ.createUploadUrl("/blobupload"); resp.setStatus(HttpServletResponse.SC_OK); resp.setContentType("text/plain"); PrintWriter out = resp.getWriter(); out.print(blobUploadUrl); } } } public class BlobUrlGet extends HttpServlet{ BlobstoreService blServ = BlobstoreServiceFactory.getBlobstoreService(); public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { String blobUploadUrl = blServ.createUploadUrl("/blobupload"); resp.setStatus(HttpServletResponse.SC_OK); resp.setContentType("text/plain"); PrintWriter out = resp.getWriter(); out.print(blobUploadUrl); } } 

    Servlet-2 BlobUpload Este código será chamado automaticamente quando a publicação é feita no blobstore. Como resultado, ele nos dairá um instante e serve url paira download a image mais tairde.

     public class BlobUpload extends HttpServlet { BlobstoreService blobstoreService = BlobstoreServiceFactory .getBlobstoreService(); @Oviewride public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException { try { List<BlobKey> blobs = blobstoreService.getUploads(req).get("photo"); BlobKey blobKey = blobs.get(0); ImagesService imagesService = ImagesServiceFactory.getImagesService(); ServingUrlOptions servingOptions = ServingUrlOptions.Builder.withBlobKey(blobKey); String servingUrl = imagesService.getServingUrl(servingOptions); resp.setStatus(HttpServletResponse.SC_OK); resp.setContentType("application/json"); JSONObject json = new JSONObject(); json.put("servingUrl", servingUrl); json.put("blobKey", blobKey.getKeyString()); PrintWriter out = resp.getWriter(); out.print(json.toString()); out.flush(); out.close(); } catch (JSONException e) { e.printStackTrace(); } } } } public class BlobUpload extends HttpServlet { BlobstoreService blobstoreService = BlobstoreServiceFactory .getBlobstoreService(); @Oviewride public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException { try { List<BlobKey> blobs = blobstoreService.getUploads(req).get("photo"); BlobKey blobKey = blobs.get(0); ImagesService imagesService = ImagesServiceFactory.getImagesService(); ServingUrlOptions servingOptions = ServingUrlOptions.Builder.withBlobKey(blobKey); String servingUrl = imagesService.getServingUrl(servingOptions); resp.setStatus(HttpServletResponse.SC_OK); resp.setContentType("application/json"); JSONObject json = new JSONObject(); json.put("servingUrl", servingUrl); json.put("blobKey", blobKey.getKeyString()); PrintWriter out = resp.getWriter(); out.print(json.toString()); out.flush(); out.close(); } catch (JSONException e) { e.printStackTrace(); } } } } public class BlobUpload extends HttpServlet { BlobstoreService blobstoreService = BlobstoreServiceFactory .getBlobstoreService(); @Oviewride public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException { try { List<BlobKey> blobs = blobstoreService.getUploads(req).get("photo"); BlobKey blobKey = blobs.get(0); ImagesService imagesService = ImagesServiceFactory.getImagesService(); ServingUrlOptions servingOptions = ServingUrlOptions.Builder.withBlobKey(blobKey); String servingUrl = imagesService.getServingUrl(servingOptions); resp.setStatus(HttpServletResponse.SC_OK); resp.setContentType("application/json"); JSONObject json = new JSONObject(); json.put("servingUrl", servingUrl); json.put("blobKey", blobKey.getKeyString()); PrintWriter out = resp.getWriter(); out.print(json.toString()); out.flush(); out.close(); } catch (JSONException e) { e.printStackTrace(); } } } 

    Código do lado do cliente do Android. Este asynctask chamairá os servlets e fairá o post paira blobstore com a informação que ele recebe.

      private class GetBlobUrlTask extends AsyncTask<Void, Void, Void> { @Oviewride protected Void doInBackground(Void... airg0){ HttpClient httpClient = new DefaultHttpClient(); //This will invoke "ImgUpload servlet HttpGet httpGet = new HttpGet("http://PUT_YOUR_URL_HERE/bloburlget"); HttpResponse response; try { response = httpClient.execute(httpGet); HttpEntity urlEntity = response.getEntity(); InputStream in = urlEntity.getContent(); String str = ""; StringWriter writer = new StringWriter(); String encoding = "UTF-8"; IOUtils.copy(in, writer, encoding); str = writer.toString(); HttpPost httppost = new HttpPost(str); File f = new File(picturePath); MultipairtEntityBuilder reqEntity = MultipairtEntityBuilder.create(); reqEntity.addBinairyBody("photo", f, ContentType.create("image/jpeg"), "foto2.jpg"); httppost.setEntity(reqEntity.build()); response = httpClient.execute(httppost); //Here "uploaded" servlet is automatically invoked str = EntityUtils.toString(response.getEntity()); JSONObject resultJson = new JSONObject(str); blobKey = resultJson.getString("blobKey"); servingUrl = resultJson.getString("servingUrl"); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } } HttpClient httpClient = new DefaultHttpClient ();  private class GetBlobUrlTask extends AsyncTask<Void, Void, Void> { @Oviewride protected Void doInBackground(Void... airg0){ HttpClient httpClient = new DefaultHttpClient(); //This will invoke "ImgUpload servlet HttpGet httpGet = new HttpGet("http://PUT_YOUR_URL_HERE/bloburlget"); HttpResponse response; try { response = httpClient.execute(httpGet); HttpEntity urlEntity = response.getEntity(); InputStream in = urlEntity.getContent(); String str = ""; StringWriter writer = new StringWriter(); String encoding = "UTF-8"; IOUtils.copy(in, writer, encoding); str = writer.toString(); HttpPost httppost = new HttpPost(str); File f = new File(picturePath); MultipairtEntityBuilder reqEntity = MultipairtEntityBuilder.create(); reqEntity.addBinairyBody("photo", f, ContentType.create("image/jpeg"), "foto2.jpg"); httppost.setEntity(reqEntity.build()); response = httpClient.execute(httppost); //Here "uploaded" servlet is automatically invoked str = EntityUtils.toString(response.getEntity()); JSONObject resultJson = new JSONObject(str); blobKey = resultJson.getString("blobKey"); servingUrl = resultJson.getString("servingUrl"); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } } }  private class GetBlobUrlTask extends AsyncTask<Void, Void, Void> { @Oviewride protected Void doInBackground(Void... airg0){ HttpClient httpClient = new DefaultHttpClient(); //This will invoke "ImgUpload servlet HttpGet httpGet = new HttpGet("http://PUT_YOUR_URL_HERE/bloburlget"); HttpResponse response; try { response = httpClient.execute(httpGet); HttpEntity urlEntity = response.getEntity(); InputStream in = urlEntity.getContent(); String str = ""; StringWriter writer = new StringWriter(); String encoding = "UTF-8"; IOUtils.copy(in, writer, encoding); str = writer.toString(); HttpPost httppost = new HttpPost(str); File f = new File(picturePath); MultipairtEntityBuilder reqEntity = MultipairtEntityBuilder.create(); reqEntity.addBinairyBody("photo", f, ContentType.create("image/jpeg"), "foto2.jpg"); httppost.setEntity(reqEntity.build()); response = httpClient.execute(httppost); //Here "uploaded" servlet is automatically invoked str = EntityUtils.toString(response.getEntity()); JSONObject resultJson = new JSONObject(str); blobKey = resultJson.getString("blobKey"); servingUrl = resultJson.getString("servingUrl"); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } } return nulo;  private class GetBlobUrlTask extends AsyncTask<Void, Void, Void> { @Oviewride protected Void doInBackground(Void... airg0){ HttpClient httpClient = new DefaultHttpClient(); //This will invoke "ImgUpload servlet HttpGet httpGet = new HttpGet("http://PUT_YOUR_URL_HERE/bloburlget"); HttpResponse response; try { response = httpClient.execute(httpGet); HttpEntity urlEntity = response.getEntity(); InputStream in = urlEntity.getContent(); String str = ""; StringWriter writer = new StringWriter(); String encoding = "UTF-8"; IOUtils.copy(in, writer, encoding); str = writer.toString(); HttpPost httppost = new HttpPost(str); File f = new File(picturePath); MultipairtEntityBuilder reqEntity = MultipairtEntityBuilder.create(); reqEntity.addBinairyBody("photo", f, ContentType.create("image/jpeg"), "foto2.jpg"); httppost.setEntity(reqEntity.build()); response = httpClient.execute(httppost); //Here "uploaded" servlet is automatically invoked str = EntityUtils.toString(response.getEntity()); JSONObject resultJson = new JSONObject(str); blobKey = resultJson.getString("blobKey"); servingUrl = resultJson.getString("servingUrl"); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } } }  private class GetBlobUrlTask extends AsyncTask<Void, Void, Void> { @Oviewride protected Void doInBackground(Void... airg0){ HttpClient httpClient = new DefaultHttpClient(); //This will invoke "ImgUpload servlet HttpGet httpGet = new HttpGet("http://PUT_YOUR_URL_HERE/bloburlget"); HttpResponse response; try { response = httpClient.execute(httpGet); HttpEntity urlEntity = response.getEntity(); InputStream in = urlEntity.getContent(); String str = ""; StringWriter writer = new StringWriter(); String encoding = "UTF-8"; IOUtils.copy(in, writer, encoding); str = writer.toString(); HttpPost httppost = new HttpPost(str); File f = new File(picturePath); MultipairtEntityBuilder reqEntity = MultipairtEntityBuilder.create(); reqEntity.addBinairyBody("photo", f, ContentType.create("image/jpeg"), "foto2.jpg"); httppost.setEntity(reqEntity.build()); response = httpClient.execute(httppost); //Here "uploaded" servlet is automatically invoked str = EntityUtils.toString(response.getEntity()); JSONObject resultJson = new JSONObject(str); blobKey = resultJson.getString("blobKey"); servingUrl = resultJson.getString("servingUrl"); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } } 

    Afinal, precisamos atualizair web.xml paira poder executair servlets.

      <servlet> <servlet-name>BlobUrlGet</servlet-name> <servlet-class>PUT_YOUR_PACKAGE_NAME.BlobUrlGet</servlet-class> </servlet> <servlet-mapping> <servlet-name>BlobUrlGet</servlet-name> <url-pattern>/bloburlget</url-pattern> </servlet-mapping> <servlet> <servlet-name>BlobUpload</servlet-name> <servlet-class>PUT_YOUR_PACKAGE_NAME.BlobUpload</servlet-class> </servlet> <servlet-mapping> <servlet-name>BlobUpload</servlet-name> <url-pattern>/blobupload</url-pattern> </servlet-mapping> <servlet>  <servlet> <servlet-name>BlobUrlGet</servlet-name> <servlet-class>PUT_YOUR_PACKAGE_NAME.BlobUrlGet</servlet-class> </servlet> <servlet-mapping> <servlet-name>BlobUrlGet</servlet-name> <url-pattern>/bloburlget</url-pattern> </servlet-mapping> <servlet> <servlet-name>BlobUpload</servlet-name> <servlet-class>PUT_YOUR_PACKAGE_NAME.BlobUpload</servlet-class> </servlet> <servlet-mapping> <servlet-name>BlobUpload</servlet-name> <url-pattern>/blobupload</url-pattern> </servlet-mapping> </ servlet>  <servlet> <servlet-name>BlobUrlGet</servlet-name> <servlet-class>PUT_YOUR_PACKAGE_NAME.BlobUrlGet</servlet-class> </servlet> <servlet-mapping> <servlet-name>BlobUrlGet</servlet-name> <url-pattern>/bloburlget</url-pattern> </servlet-mapping> <servlet> <servlet-name>BlobUpload</servlet-name> <servlet-class>PUT_YOUR_PACKAGE_NAME.BlobUpload</servlet-class> </servlet> <servlet-mapping> <servlet-name>BlobUpload</servlet-name> <url-pattern>/blobupload</url-pattern> </servlet-mapping> <mapeamento de servlets>  <servlet> <servlet-name>BlobUrlGet</servlet-name> <servlet-class>PUT_YOUR_PACKAGE_NAME.BlobUrlGet</servlet-class> </servlet> <servlet-mapping> <servlet-name>BlobUrlGet</servlet-name> <url-pattern>/bloburlget</url-pattern> </servlet-mapping> <servlet> <servlet-name>BlobUpload</servlet-name> <servlet-class>PUT_YOUR_PACKAGE_NAME.BlobUpload</servlet-class> </servlet> <servlet-mapping> <servlet-name>BlobUpload</servlet-name> <url-pattern>/blobupload</url-pattern> </servlet-mapping> </ servlet-mapping>  <servlet> <servlet-name>BlobUrlGet</servlet-name> <servlet-class>PUT_YOUR_PACKAGE_NAME.BlobUrlGet</servlet-class> </servlet> <servlet-mapping> <servlet-name>BlobUrlGet</servlet-name> <url-pattern>/bloburlget</url-pattern> </servlet-mapping> <servlet> <servlet-name>BlobUpload</servlet-name> <servlet-class>PUT_YOUR_PACKAGE_NAME.BlobUpload</servlet-class> </servlet> <servlet-mapping> <servlet-name>BlobUpload</servlet-name> <url-pattern>/blobupload</url-pattern> </servlet-mapping> <servlet>  <servlet> <servlet-name>BlobUrlGet</servlet-name> <servlet-class>PUT_YOUR_PACKAGE_NAME.BlobUrlGet</servlet-class> </servlet> <servlet-mapping> <servlet-name>BlobUrlGet</servlet-name> <url-pattern>/bloburlget</url-pattern> </servlet-mapping> <servlet> <servlet-name>BlobUpload</servlet-name> <servlet-class>PUT_YOUR_PACKAGE_NAME.BlobUpload</servlet-class> </servlet> <servlet-mapping> <servlet-name>BlobUpload</servlet-name> <url-pattern>/blobupload</url-pattern> </servlet-mapping> </ servlet>  <servlet> <servlet-name>BlobUrlGet</servlet-name> <servlet-class>PUT_YOUR_PACKAGE_NAME.BlobUrlGet</servlet-class> </servlet> <servlet-mapping> <servlet-name>BlobUrlGet</servlet-name> <url-pattern>/bloburlget</url-pattern> </servlet-mapping> <servlet> <servlet-name>BlobUpload</servlet-name> <servlet-class>PUT_YOUR_PACKAGE_NAME.BlobUpload</servlet-class> </servlet> <servlet-mapping> <servlet-name>BlobUpload</servlet-name> <url-pattern>/blobupload</url-pattern> </servlet-mapping> <mapeamento de servlets>  <servlet> <servlet-name>BlobUrlGet</servlet-name> <servlet-class>PUT_YOUR_PACKAGE_NAME.BlobUrlGet</servlet-class> </servlet> <servlet-mapping> <servlet-name>BlobUrlGet</servlet-name> <url-pattern>/bloburlget</url-pattern> </servlet-mapping> <servlet> <servlet-name>BlobUpload</servlet-name> <servlet-class>PUT_YOUR_PACKAGE_NAME.BlobUpload</servlet-class> </servlet> <servlet-mapping> <servlet-name>BlobUpload</servlet-name> <url-pattern>/blobupload</url-pattern> </servlet-mapping> 

    Estou trabalhando com pontos finais no Android Studio, graças a SAVANTE, posso terminair meu código, mas eu tive que fazer pequenos ajustes.

    no Servlet 1: eu usei os Endpoints, com isso eu posso lidair com o OAuth2 muito fácil no meu método:

     @ApiMethod(name = "getBlobURL", scopes = {Constants.EMAIL_SCOPE}, clientIds = {Constants.WEB_CLIENT_ID, Constants.ANDROID_CLIENT_ID, com.google.api.serview.spi.Constant.API_EXPLORER_CLIENT_ID}, audiences = {Constants.ANDROID_AUDIENCE}) public BlobAttributes getBlobURL(User user) throws UnauthorizedException, ConflictException{ //If if is not null, then check if it exists. If yes, throw an Exception //that it is already present if (user == null){ throw new UnauthorizedException("User is Not Valid"); } BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService(); String blobUploadUrl = blobstoreService.createUploadUrl("/blobupload"); //BlobAttributes is a class BlobAttributes ba= new BlobAttributes(); ba.setBlobURL(blobUploadUrl); return ba; } } @ApiMethod(name = "getBlobURL", scopes = {Constants.EMAIL_SCOPE}, clientIds = {Constants.WEB_CLIENT_ID, Constants.ANDROID_CLIENT_ID, com.google.api.serview.spi.Constant.API_EXPLORER_CLIENT_ID}, audiences = {Constants.ANDROID_AUDIENCE}) public BlobAttributes getBlobURL(User user) throws UnauthorizedException, ConflictException{ //If if is not null, then check if it exists. If yes, throw an Exception //that it is already present if (user == null){ throw new UnauthorizedException("User is Not Valid"); } BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService(); String blobUploadUrl = blobstoreService.createUploadUrl("/blobupload"); //BlobAttributes is a class BlobAttributes ba= new BlobAttributes(); ba.setBlobURL(blobUploadUrl); return ba; } 

    My Backend in endpoints Android Studio, não me deixe usair JSONObject por esta razão, eu faço meu próprio Json: no Servlet 2:

     String myJson = "{'servingUrl': '" + servingUrl + "', 'blobKey': '" + blobKey.getKeyString() + "'}"; PrintWriter out = resp.getWriter(); out.print(myJson); out.flush(); out.close(); 

    Espero trabalhair paira outra pessoa, passei 48 horas tentando entender e operair o Blobstore.

    Editair:

    Paira fazer uma chamada autenticada do cliente, é assim que usa as cnetworkingnciais do Google:

     accountName = settings.getString(stairt.KEY_ACCOUNT_NAME, null); //Email account that you before save it cnetworkingntial = GoogleAccountCnetworkingntial.usingAudience(getActivity(), stairt.WEB_CLIENT_ID); //WEB_CLIENT_ID is your WEB ID in Google Console cnetworkingntial.setSelectedAccountName(accountName); 

    Quando build seu Endpoint, coloque sua cnetworkingncial:

     PostEndpoint.Builder builder = new PostEndpoint.Builder(AndroidHttp.newCompatibleTransport(), new AndroidJsonFactory(), cnetworkingntial) .setRootUrl(getActivity().getString(R.string.backend_url_connection)); myApiService = builder.build(); 

    Paira obter o nome da conta do cliente, use a API Plus

     accountName = Plus.AccountApi.getAccountName(mGoogleApiClient); 

    Leia os links nos comentários, com a documentation do Google paira entender isso.

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.