10

The Problem

When uploading a file using the Go Blobstore API, the success path redirects to the wrong appengine module. Here is a more visual description of the problem:

  1. User lands on the upload page of module A: http://A.my-appengine-app.com/upload
  2. User's browser makes a request to the module for an upload session: http://A.my-appengine-app.com/upload/session
  3. Module A defines a handler for /upload/session which runs the following Go code: url, err := blobstore.UploadURL(c, "/upload/success")
  4. The method returns a URL, similar to: http://A.my-appengine-app.com/_ah/upload/[some long hash]/
  5. This URL is relayed back to the user's browser and inserted into the action of a <form>.
  6. The user submits a multipart POST request to the URL
  7. Whatever handles the URL (some non-user-space appengine handler), attempts to redirect back to /upload/success

This is where things get weird. In development, the server redirects to "/upload/success" in module A. In production, the server redirects to the main module, which we can call B for now. I can tell this is happening because I am getting a 404 in my web console and the logs indicate that the request is being made to module B. I've even gone so far as to explicitly pass the hostname as part of the success path (step #3), but to no effect.

Current Solution (Not Ideal)

It seems my only recourse is to define a handler in module B to handle the request as module A would. Since the goapp architecture globs all the modules together, this isn't the worst tradeoff in the world, but it's semantically wrong given that modules are supposed to be vertically independent. If anyone has any idea how to work around this, I'd be obliged. For now, I'll take the aforementioned approach.

Harshal Patil
  • 6,284
  • 8
  • 37
  • 55
  • Also [filed a ticket on the official tracker](https://code.google.com/p/googleappengine/issues/detail?id=10927); hopefully that gets some traction too. – Jonathan Azoff May 13 '14 at 19:54
  • 1
    It's still seems like a hack, but you could try using dispatch.yaml to match the post-upload URL and have it handled by your module-A. Then at least the code is part of the correct module. – Greg May 13 '14 at 20:17
  • 2
    @JonathanAzoff The link to the ticket responses 403. – hiroshi Jul 25 '14 at 07:02
  • 1
    This is almost five years old - is this still a thing? – John Weldon Feb 01 '19 at 16:47

0 Answers0