Reputation: 7685
I am looking at writing a Java web application on Google App Engine. I want to be able to upload and serve images from the app but just realised that the Datastore have a 1MB limit. This is slightly too little for decent pictures. Is there an alternative way you can suggest of doing this? Perhaps storing those as static content rather than in the Datastore but there seems to be no API for this.
Upvotes: 5
Views: 4564
Reputation: 21688
Now Google App enigne provides Image API which is different from Blobstore API. this is improved and specially for Images. you can try that.
https://cloud.google.com/appengine/docs/java/images/
Upvotes: 0
Reputation: 8842
Now it is possible on GAE. Simply you have to store your files in Blobstore. You can upload your files like this:
<body>
<form action="<%= blobstoreService.createUploadUrl("/upload") %>" method="post" enctype="multipart/form-data">
<input type="file" name="myFile">
<input type="submit" value="Submit">
</form>
And then to serve file from servlet:
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws IOException {
BlobKey blobKey = new BlobKey(req.getParameter("blob-key"));
blobstoreService.serve(blobKey, res);
Upvotes: 4
Reputation: 101149
You can't write to the filesystem in App Engine, so static content is out for now - but an API for storing and serving blobs is on the roadmap. In the meantime, your best bet is to split the file into chunks, and store those in the datastore, or to use an external service like S3.
Upvotes: 2
Reputation: 59175
There is no easy way today, but that can change later.
The best you can do right now is to vote (star) the request to add Google File System support to appengine in their issue tracker:
Upvotes: 1