I'm trying to setup a Google Cloud Storage file upload by following the sample from google with the GcsExampleServlet.java . I've complete all the step but when I deploy the project to aggengine and I try to upload a simple text in GCS , it fail 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)
(...)
Still, there is nothing complicate in the code... In web.xml I've 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 servlet GcsExampleServlet.java ( exactly the same as in google sample ) :
@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've enabled Billing, created a bucket but the AppIdentity error still appear. I've no Oauth, the cloud storage API is enabled, the appengine account used to upload has write access to the bucket. I even tried a
gsutil acl ch -u [email protected]:WRITE gs://ctrlxbucket
To be sure that the user has write access to my bucket.
Please help me to figure out what this error mean, I'm stick here since days :(
Thanks a lot
PS : If you just have some working sample of GCS ( not the google one ), I'll be happy too since there is not a lot of stuff around that topic.
Google App Engine (GAE) is a platform-as-a-service product that provides web app developers and enterprises with access to Google's scalable hosting and tier 1 internet service. GAE requires that applications be written in Java or Python, store data in Google Bigtable and use the Google query language.
App Engine is a fully managed, serverless platform for developing and hosting web applications at scale. You can choose from several popular languages, libraries, and frameworks to develop your apps, and then let App Engine take care of provisioning servers and scaling your app instances based on demand.
Download and Install You can download the Google App Engine SDK by going to: http://code.google.com/appengine/downloads.html and download the appropriate install package. Download the Windows installer – the simplest thing is to download it to your Desktop or another folder that you remember.
App Engine standard environment pricing. Apps in the standard environment have a free tier for App Engine resources. Any use of App Engine resources beyond the free tier incurs charges as described in this section. To estimate costs for App Engine resources in the standard environment, use the pricing calculator.
Instead of [email protected] try using [email protected] (replace XXX with your application's project id - taken from "Google APIs Console Project Number" in the" Administration/Application Settings" of the admin console).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With