REST API を使用して appengine から Google ストレージにファイルを書き込んでいます。
私のコードは次のようになります。
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)
Google ストレージ API ドキュメントに従って、REST API は、オブジェクトの ACL を変更できる「x-goog-acl」ヘッダーを取得します。
ただし、このオブジェクトが作成された後でも、ACL は public-read に設定されていません。gsutil と GS ブラウザの両方から確認できます。
誰かが私が間違っていることを教えてもらえますか?
編集: jterrace は、ヘッダーをリクエストに渡していないことを指摘しました。私はそれを修正しました。ただし、オブジェクトに public-read ACL はまだ設定されていません。