Reputation: 47
Not sure if this is exactly the same as NotFoundError: Expect status [200] from Google Storage. But got status 404 while reading a file but I have the same problem and I couldn't find a resolution there. I used the Browser to upload a file players2018 to my storage bucket. it's there and I can see it fine in the storage cloud browser. I'm definitely resolving with the right bucket name, which is just the name of my app and it is the same name that appears when I get a link to the file from the Cloud browser. So here's the relevant code:
def bucket_name():
os.environ.get('BUCKET_NAME', app_identity.get_default_gcs_bucket_name())
return app_identity.get_default_gcs_bucket_name()
def read_file(filename):
fn = "/" + bucket_name() + "/" + filename
logging.debug("Reading" + fn)
with cloudstorage.open(fn) as cloudstorage_file:
return cloudstorage_file.readlines()
And I get back:
NotFoundError: Expect status [200] from Google Storage. But got status 404.
Path: '/[Actual Bucket Name]/players2018'.
Request headers: None.
Response headers: {'connection': 'close', 'date': 'Thu, 08 Mar 2018 02:25:32 GMT', 'server': 'Development/2.0'}.
Body: ''.
Extra info: None.
I changed the bucket name to protect the clueless, namely me.
Upvotes: 0
Views: 527
Reputation: 1572
This documentation, that you mentioned in a comment, seems to be at least partly outdated at the moment. Instead try using the following example. If you follow the instructions from that first outdated link, files stored to the bucket are not sent over the internet; there is a simulation of that happening instead.
I assume you are using the following repository:
$ git clone https://github.com/GoogleCloudPlatform/appengine-gcs-client.git
Notice that the bucket name is unnecessary for this demo to work because the library for Cloud Storage referenced in this repository actually uses blobstore. Blobstore simulates Cloud Storage access by using local Datastore emulator.
I copied the contents from directory python/cloudstorage
(note that src
is missing from the path) into directory demo
.
You can check it for yourself. All files should be listed there like this:
Note: I commented out this line in demo/main.py
; you might want to do the same:
#self.delete_files()
Upvotes: 0
Reputation: 16553
I believe the problem relates to permissions. The app on the dev server has a different name than the deployed app. The deployed app has a name like s~myappname
. The app on the dev server will have a name like dev~myappname
or sometimes dev~None
.
When your dev server goes to cloud storage to get the file, cloud storage does not recognize the dev server as the owner of that bucket and refuses to provide the file.
To test this, you could make the file on Google Cloud Storage publicly available. If the dev server works afterwards, that was the problem.
Other than making the file publicly available, I'm not sure how to share the file with the dev server. Google's sharing of things between projects is confusing, but you might be able to accomplish it.
Upvotes: 1