Blobstore upload redirects to wrong module
Asked Answered
R

0

13

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.

Ruel answered 13/5, 2014 at 19:38 Comment(4)
Also filed a ticket on the official tracker; hopefully that gets some traction too.Ruel
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.Tisbee
@JonathanAzoff The link to the ticket responses 403.Door
This is almost five years old - is this still a thing?Palmerpalmerston

© 2022 - 2024 — McMap. All rights reserved.