I created the bucket, upload a file via
gsutil cp -a public-read test.htm gs://BUCKETNAME
I can see the file in the Storage Browser and with gsutil ls
When I try to read it with the following code, I get
NotFoundError: Expect status [200] from Google Storage. But got status 404.
Code:
import logging
import os
import lib.cloudstorage as gcs
import webapp2
from google.appengine.api import app_identity
my_default_retry_params = gcs.RetryParams(initial_delay=0.2,
max_delay=5.0,
backoff_factor=2,
max_retry_period=50)
gcs.set_default_retry_params(my_default_retry_params)
class MainPage(webapp2.RequestHandler):
def get(self):
bucket_name = os.environ.get('BUCKET_NAME',
app_identity.get_default_gcs_bucket_name())
self.response.headers['Content-Type'] = 'text/plain'
self.response.write('Demo GCS Application running from Version: '
+ os.environ['CURRENT_VERSION_ID'] + '\n')
self.response.write('Using bucket name: ' + bucket_name + '\n\n')
bucket = '/' + bucket_name
filename = bucket + '/test.htm'
self.read_file(filename)
def read_file(self, filename):
self.response.write('Abbreviated file content (first line and last 1K):\n')
gcs_file = gcs.open(filename)
self.response.write(gcs_file)
app = webapp2.WSGIApplication([
('/', MainPage),
], debug=True)
Strage thing happens, when I use the sample code from here (https://github.com/GoogleCloudPlatform/appengine-gcs-client/blob/master/python/demo/main.py) in my environment.
The code creates and writes a file on the same bucket, then reads it and deletes it. Works fine, but when I comment out the delete parts, I can not see the files in Storage Browser or with gsutil, but I can still read them with the code.
I checked my bucket permissions in Storage Browser and they seem fine, the service account of the app is bucket owner.
Any help is greatly appreciated.