I am writing files into Google storage from appengine using REST api.
My code looks like this:
url = 'http://storage.googleapis.com/' + bucketName + filePath
LOG.debug('Attempting to write file: ' + url)
'''
compute expiry time one year in the future
'''
expiresDate = datetime.utcnow() + timedelta(days=zconfig.CACHE_EXPDAY)
formatStr = '%a, %d %b %Y %H:%M:%S GMT'
start_cloud = time.time()
headers = {'Content-Type' : mime,
'Content-Length' : len(imageBytes),
'Cache-Control' : 'Expires=' + expiresDate.strftime(formatStr),
'x-goog-api-version' : '2',
'x-goog-acl' : 'public-read'}
resp, content = http.request(url, 'PUT', body=imageBytes, headers=headers)
As per the google storage api docs, the REST api takes a 'x-goog-acl' header that can change the ACl on the object.
However, after this object is created, the ACL is still not set to public-read. I can see that both from gsutil, as well as from the GS browser.
Can someone tell me what I am doing wrong?
EDIT: jterrace pointed out that I am not passing the headers into the request. I fixed that. But it still does not set the public-read ACL on the object.