Google Appengine and cloud storage: AppIdentity service unexpectedly encountered an error

I am trying to customize the download of Google Cloud Storage files by following a sample from Google using GcsExampleServlet.java. I completed the whole step, but when I deploy the project for aggengine and I try to load plain text in GCS, it fails with this log:

com.google.appengine.tools.cloudstorage.NonRetriableException: com.google.appengine.tools.cloudstorage.NonRetriableException: com.google.appengine.api.appidentity.AppIdentityServiceFailureException: The AppIdentity service threw an unexpected error. Details: at com.google.appengine.tools.cloudstorage.RetryHelper.doRetry(RetryHelper.java:120) at com.google.appengine.tools.cloudstorage.RetryHelper.runWithRetries(RetryHelper.java:166) at com.google.appengine.tools.cloudstorage.RetryHelper.runWithRetries(RetryHelper.java:156) at com.google.appengine.tools.cloudstorage.GcsServiceImpl.createOrReplace(GcsServiceImpl.java:70) at com.appart.storage.server.GcsExampleServlet.doPost(GcsExampleServlet.java:88) at javax.servlet.http.HttpServlet.service(HttpServlet.java:637) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166) (...) 

However, there is nothing complicated in the code ... In web.xml, I configured the servlet:

 <servlet> <servlet-name>GcsExample</servlet-name> <servlet-class> com.example.server.GcsExampleServlet </servlet-class> </servlet> <servlet-mapping> <servlet-name>GcsExample</servlet-name> <url-pattern>/gcs/*</url-pattern> </servlet-mapping> 

Here is the GcsExampleServlet.java servlet (exactly the same as in the Google example):

 @SuppressWarnings("serial") public class GcsExampleServlet extends HttpServlet { private final GcsService gcsService = GcsServiceFactory.createGcsService(new RetryParams.Builder() .initialRetryDelayMillis(10) .retryMaxAttempts(10) .totalRetryPeriodMillis(15000) .build()); //... @Override public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException { GcsOutputChannel outputChannel = gcsService.createOrReplace(getFileName(req), GcsFileOptions.getDefaultInstance()); copy(req.getInputStream(), Channels.newOutputStream(outputChannel)); } private void copy(InputStream input, OutputStream output) throws IOException { try { byte[] buffer = new byte[BUFFER_SIZE]; int bytesRead = input.read(buffer); while (bytesRead != -1) { output.write(buffer, 0, bytesRead); bytesRead = input.read(buffer); } } finally { input.close(); output.close(); } } } 

Here is my upload.html file:

 <form action="/upload.html" enctype="text/plain" method="get" name="putFile" id="putFile"> <div> Bucket: <input type="text" name="bucket" /> File Name: <input type="text" name="fileName" /> <br /> File Contents: <br /> <textarea name="content" id="content" rows="3" cols="60"></textarea> <br /> <input type="submit" onclick='uploadFile(this)' value="Upload Content" /> </div> </form> <script> function uploadFile() { var bucket = document.forms["putFile"]["bucket"].value; var filename = document.forms["putFile"]["fileName"].value; if (bucket == null || bucket == "" || filename == null || filename == "") { alert("Both Bucket and FileName are required"); return false; } else { var postData = document.forms["putFile"]["content"].value; document.getElementById("content").value = null; var request = new XMLHttpRequest(); request.open("POST", "/gcs/" + bucket + "/" + filename, false); request.setRequestHeader("Content-Type", "text/plain;charset=UTF-8"); request.send(postData); } } </script> 

I turned on Billing, created a bucket, but the AppIdentity error still appears. I don't have Oauth, the cloud storage API is enabled, the appengine account used to download has write access to the bucket. I even tried

 gsutil acl ch -u warm-particle-718@appspot.gserviceaccount.com:WRITE gs://ctrlxbucket 

To make sure the user has write access to my bucket.

Please help me figure out what this error means, I have been sticking here since: (

Thank you so much

PS: If you just have a working GCS model (not Google), I will also be happy, since there are not many in this topic.

+8
java google-app-engine google-cloud-storage
source share
1 answer

Instead of warm-particle-718@appspot.gserviceaccount.com try using XXX@developer.gserviceaccount.com (replace XXX with your application project identifier - from "Google API API Console Project Number" in "Administration / Application Settings" in the admin console) .

+1
source share

All Articles