Katedral Pillon
Katedral Pillon

Reputation: 14864

What to pass to `blobstoreService.createUploadUrl` so it is handled by my endpoint method

My question is similar to getting blobstore to callback to endpoint method but s/he got no reply. Also I actually wrote my code. I created my callback url as

BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
String url = blobstoreService.createUploadUrl("/loadImages");

And then I created my endpoint as

@ApiMethod(name = "loadImages", httpMethod = HttpMethod.POST)
public void loadImages(javax.servlet.http.HttpServletRequest req) {
  //…. get blob key etc.
}

Then I get an error on my server when the blobstore makes the callback call:

No handlers matched this URL. (404)

Does anyone know what to pass to blobstoreService.createUploadUrl so it is handled by my endpoint method?

I have also tried changing ”/loadImages” to "/_ah/spi/com.company.package.ApiName.loadImages” so that it looks like the other paths, but that didn’t work either. Then I tried "_ah/api/apiname/1/loadImages”: nothing.

Note: I am not looking for an alternative to the blobstore/endpoint. When I use simple servlet to receive the callback it works. But the servlet just cheapens my otherwise endpoint-only code.

Upvotes: 2

Views: 847

Answers (1)

tomrozb
tomrozb

Reputation: 26251

I'm afraid you can only user servlets to handle this type of callback. I've been looking for solution for several hours and found this topic.

In short:

The form must include a file upload field, and the form's enctype must be set to multipart/form-data. The API ... passes the rewritten request to your application on the given path as a blob key.

As Endpoints doesn't (as far as I know) accept multipart/form-data as a valid encoding, this won't work. The error messaging you see is because the Endpoint is expecting JSON.

Upvotes: 1

Related Questions