1

I am trying to access files that are hosted on a remote cloud storage bucket through the dev_appserver.py dev server.

This direct link to google cloud storage works:

https://leanplum-wordpress.storage.googleapis.com/leanplum-black.svg

where as the local via the dev_appserver does not:

http://localhost:8080/_ah/gcs/leanplum-black.svg

Log Output:

INFO     2016-07-06 22:37:16,461 module.py:788] default: "GET /_ah/gcs/leanplum-black.svg HTTP/1.1" 200 116

I am running the dev server like this:

dev_appserver.py --default_gcs_bucket_name=leanplum-wordpress .

What's wrong?

BrettJ
  • 6,801
  • 1
  • 23
  • 26
electronix384128
  • 6,625
  • 11
  • 45
  • 67
  • According to this post: http://stackoverflow.com/a/29664200/2302437 It should work like mentioned above... There also seems to be no docs from Google on this :/ – electronix384128 Jul 06 '16 at 22:44
  • That request is returning a 200, so it appears to be working. Have you logged the response contents to see what it is? – GAEfan Jul 07 '16 at 23:55

3 Answers3

2

You need to make sure that auth will be configured with your google cloud project and that the client will connect to the production google cloud storage rather than the local development (which happens by default when local development server run is detected).

See here.

ozarov
  • 1,051
  • 6
  • 7
0

I believe you need to include the bucket name:

    localhost:port/_ah/gcs/bucket_name/file_suffix 

Where port is by default 8080, and the file was written to: /bucket_name/file_suffix

It appears you went to:

   http://localhost:8080/_ah/gcs/leanplum-black.svg

But needed to include the bucket name, which may be leanplum-wordpress:

   http://localhost:8080/_ah/gcs/leanplum-wordpress/leanplum-black.svg

Note that I did not find this anywhere in the documentation. This question helped me guess that I needed to include the bucket name in the url, so I hope this helps someone else as well!

Bill Zito
  • 61
  • 1
  • 3
-1

We're still having this issue. We believe this is an issue that's originating from the Appengine Wordpress plugin.

We came up with the following workaround to get the images loading properly:

Create a Bookmarklet in Google Chrome and add the following url:

javascript:var start = var targetUrls = ["//" + window.location.host + "/wp-content/uploads/","//" + window.location.host + "/_ah/gcs/bucket-name/"];var htmlAttributes = ["src", "srcset"];jQuery("img").each(function(index, img) {targetUrls.forEach(function(pattern) {htmlAttributes.forEach(function(htmlAttr) {var htmlObj = jQuery(img).attr(htmlAttr);if (htmlObj) {jQuery(img).attr(htmlAttr, htmlObj.replace(new RegExp(pattern, "g"), "//bucket-name.storage.googleapis.com/"));}});});});

Full Code:

var targetUrls = [
    "//" + window.location.host + "/wp-content/uploads/",
    "//" + window.location.host + "/_ah/gcs/bucket-name/"
];
var htmlAttributes = ["src", "srcset"];
jQuery("img").each(function(index, img) {
    targetUrls.forEach(function(pattern) {
        htmlAttributes.forEach(function(htmlAttr) {
            var htmlObj = jQuery(img).attr(htmlAttr);
            if (htmlObj) {
                jQuery(img).attr(htmlAttr, htmlObj.replace(new RegExp(pattern, "g"), "//bucket-name.storage.googleapis.com/"));
            }
        });
    });
});
electronix384128
  • 6,625
  • 11
  • 45
  • 67