Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File upload to AppEngine Blobstore

Following this blobstore document on how to upload to the Blobstore. It shows uploading through JSP + Servlet approach.

Since my app is based on GWT, I need to adapt the for GWT RPC (instead of JSP).

So in my app RPC service implementation:

public class MyServiceImpl extends RemoteServiceServlet implements
    MyService {

  public String getUploadUrl() {
    BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
    return blobstoreService.createUploadUrl("/upload")
  }
}

Is this the right approach or is there any other way to do it properly? I haven't tried this code though.

The binary that will be uploaded range from bytes to 2MB at max.

Following this blobstore document on how to upload to the Blobstore. It shows uploading through JSP + Servlet approach.

Since my app is based on GWT, I need to adapt the for GWT RPC (instead of JSP).

So in my app RPC service implementation:

public class MyServiceImpl extends RemoteServiceServlet implements
    MyService {

  public String getUploadUrl() {
    BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
    return blobstoreService.createUploadUrl("/upload")
  }
}

Is this the right approach or is there any other way to do it properly? I haven't tried this code though.

The binary that will be uploaded range from bytes to 2MB at max.

When I tried out this code, this is the server side console log:

May 07, 2012 6:35:53 AM com.google.appengine.tools.development.LocalResourceFileServlet doGet
WARNING: No file found for: /crossdomain.xml

Then on the client side GWT.log the Rpc was able to generate a URL however it does not work:

[INFO] [blobrpc] - Success fetch upload url: http://127.0.0.1:8888/_ah/upload/aglub19hcHBfaWRyGwsSFV9fQmxvYlVwbG9hZFNlc3Npb25fXxgDDA
like image 592
quarks Avatar asked Dec 05 '25 15:12

quarks


1 Answers

createUploadUrl() creates a Url that expects a HTTP POST with Content-type header multipart/form-data.

If you want to use GWT-RPC than you need to use Blobstore FileService API to create file on server side.

like image 92
Peter Knego Avatar answered Dec 08 '25 16:12

Peter Knego



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!