Skip to content
This repository has been archived by the owner on Sep 16, 2022. It is now read-only.

Does Not Work On Python Dev Server #54

Open
bmayfi3ld opened this issue Nov 26, 2016 · 4 comments
Open

Does Not Work On Python Dev Server #54

bmayfi3ld opened this issue Nov 26, 2016 · 4 comments

Comments

@bmayfi3ld
Copy link

Trying to use the python client library with the development server. Each time I try to write to the bucket I get this error:

It works fine when deployed on app engine

ServerError: Expect status [201] from Google Storage. But got status 500.
Path: '/*****mybucket******/7jj601gxnc20160925124634jpgdl0.jpg'.
Request headers: {'content-type': 'image/jpeg', 'accept-encoding': 'gzip, *', 'x-goog-api-version': '2', 'x-goog-resumable': 'start'}.
Response headers: {'server': 'Development/2.0', 'date': 'Sat, 26 Nov 2016 17:48:14 GMT', 'transfer-encoding': 'chunked'}.
Body: ''.
Extra info: None.

my python code, pretty much taken directly from https://cloud.google.com/appengine/docs/python/googlecloudstorageclient/read-write-to-cloud-storage

abbreviated version

 bucket_name = os.environ.get('BUCKET_NAME',
                               app_identity.get_default_gcs_bucket_name())
   file_name = slugify(request.args.get('pic'), separator = '')[24:] + '.jpg'
    bucket_file = '/{}/{}'.format(bucket_name, file_name) #generally turns into something like /app_default_bucket/7jj6012fnc20250925124634jpgdl0.jpg' on the development server

write_retry_params = gcs.RetryParams(backoff_factor = 1.1)
gcs_file = gcs.open(bucket_file, 'w', 'image/jpeg', retry_params = write_retry_params)
out_string.seek(0) # StringIO object
gcs_file.write(out_string.getvalue())
gcs_file.close()

As I mentioned works perfectly when deployed.

Something else I discovered I can get it to give me a 404 not found error if I just try to open random files.

@bmayfi3ld bmayfi3ld changed the title Does Not Work On Dev Server Does Not Work On Python Dev Server Nov 26, 2016
@birdchan
Copy link

Is this resolved? I have the same issue...

@Rob1080
Copy link

Rob1080 commented Jul 18, 2019

@birdchan did you find a fix for this issue? Just started happening in one of my projects now too.

@birdchan
Copy link

If I remember correctly, it has something to do with the credential json file, giving bucket read/write access to that service account at the IAM portal. The app engine app once deployed has a default service account, which may be different from the service account you have in your local credential json file.

@Rob1080
Copy link

Rob1080 commented Jul 19, 2019

@birdchan thanks for responding.
I found this issue https://issuetracker.google.com/issues/35900575 (and monkey patch fix) had been reported which seemed to be the problem I was having.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@birdchan @bmayfi3ld @Rob1080 and others