I was trying to upload a file to Google Cloud Storage with the help of a django application. I wrote this create_gcs_file function that gets called in my view:
import cloudstorage as gcs
from google.appengine.ext import blobstore
def create_gcs_file(filename, data):
with gcs.open(filename, 'w') as f:
f.write(data)
blobstore_filename = '/gs' + filename
return blobstore.create_gs_key(blobstore_filename)
I call this function in a view and pass it a filename, and some file.read() data as parameters. Here is the view code I have written that makes use of this.
But when I upload the file I get this error:
Expect status [201] from Google Storage. But got status 302
The debug page shows that the error occurs at this line:
with gcs.open(filename, 'w') as f:
P.S: I get this error when running my app with the Google App Engine SDK 1.8.5 locally.