user662264
user662264

Reputation:

Why "form POST" stay in status "PENDING" when trying to uplaod image to blobstore

When I go to https://appengine.google.com/blobstore/ I see that images are uploaded (cf. blob viewer).

In prod mode :

In chrome dev tool, when I submit the form in order to upload the image, I see that the form stay in a "PENDING" status. The purpose of this mail is to help me to understand what should fail. In the Network tab, I hae the following Header :

Request

URL:http://www.mananaseguro.com/_ah/upload/AMmfu6aImWsEdAeiy_FVrscqQiRoRSvjK2QSX6thgKTaMk4nKLbiJg86RrocrzAqWj2X2vi1gKrY_Yvr2kSQNpFMwxBiUFa1Tk5oEVZGjhMm_9SavhOAjNoteylbfLT7aZ5dUYMaDR2N/ALBNUaYAAAAAUeJL86BP_9txQLF54r96AvYfm1Nuw90l/
Request Headersview source
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Content-Type:multipart/form-data; boundary=----WebKitFormBoundarymTEOMdBbtHBxoFJb
Origin:http://www.mananaseguro.com
Referer:http://www.mananaseguro.com/
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.72 Safari/537.36
Request Payload
------WebKitFormBoundarymTEOMdBbtHBxoFJb
Content-Disposition: form-data; name="myFile"; filename="trailer-8.webp"
Content-Type: image/webp
------WebKitFormBoundarymTEOMdBbtHBxoFJb--

And in the response tab :

**This request has no data response**

I have done the following servlet configuration (GUICE) serve("/_ah/upload").with(BlobstoreUploadFinishedServlet.class); // post serve("/_ah/serve").with(Servlet_Serve.class);

And some related line of code I call :

resp.sendRedirect("/_ah/serve?blob-key=" + url);

String url = blobstoreService.createUploadUrl("/_ah/upload");

Question : Can you explain me why "I" do not have a response (form POST is always pending) ? I also do not know if I should use "/_ah/" or not (I have decided to put it everywhere) ?


I have another issue in dev mode, I cannot test upload to blobstore, because I have the following error :

WARNING: /_ah/upload/ag1tYW5hbmFzZWd1cm8xch0LEhVfX0Jsb2JVcGxvYWRTZXNzaW9uX18Y2aQCDA java.lang.NullPointerException at com.google.appengine.api.blobstore.dev.UploadBlobServlet.getSessionId(UploadBlobServlet.java:134)

Question : What is happening ? Is it a problem related to cookies ?

Thanks you,

Upvotes: 0

Views: 1546

Answers (1)

Shuky Capon
Shuky Capon

Reputation: 785

I remember dealing with this issue a while back - sadly this happens because the blobstore implementation in devmode is different from the production one.

you don't need the /_ah/ prefix and if I'm not mistaken than /_ah/upload is reserved for the blobservice so you shouldn't use it. (don't take my word on this)

This is far from optimal, but you can understand if you are in devmode on the server side by calling a utility function:

public static boolean isDevelopmentMode() {
    return ( SystemProperty.environment.value() ==
                SystemProperty.Environment.Value.Development );
}

and implementing a different logic by calling resp.sendRedirect("devmodeServe?blob-key="+blobkey); and binding that servlet to a DevmodeServeServlet class:

class DevmodeServeServlet extends HttpServlet
{
         BlobstoreService blobstoreService = BlobstoreServiceFactory
        .getBlobstoreService();

        @Override
        protected void doGet(HttpServletRequest req, HttpServletResponse resp)
                throws ServletException, IOException {

            BlobKey blobKey = new BlobKey(req.getParameter("blob-key"));
            blobstoreService.serve(blobKey, resp);

        }
}

I also don't remember why, but I think you have to use your computer name instead of 127.0.0.1 or localhost in the browser address bar (you'll might need to add it to the allowed lists in the gwt devmode plugin in your browser)

Upvotes: 1

Related Questions