I caught an error as below.
INFO ~ module.py:639] default: "HEAD /_ah/gcs/app_default_bucket/multibytes.txt HTTP/1.1" 404 -
ERROR ~ gcs.py:99] Expect status [200] from Google Storage. But got status 404.
Path: '/app_default_bucket/multibytes.txt'.
Request headers: None.
Response headers: {'date': 'Mon, 07 Jul 2014 12:59:44 GMT', 'server': 'Development/2.0', 'connection': 'close'}.
Body: ''.
Extra info: None.
Traceback (most recent call last):
File "/gcs.py", line 97, in status
stat = gcs.stat("/%s/%s" % (b,nm))
File "/cloudstorage/cloudstorage_api.py", line 142, in stat
body=content)
File "/cloudstorage/errors.py", line 132, in check_status
raise NotFoundError(msg)
NotFoundError: Expect status [200] from Google Storage. But got status 404.
Path: '/app_default_bucket/multibytes.txt'.
Request headers: None.
Response headers: {'date': 'Mon, 07 Jul 2014 12:59:44 GMT', 'server': 'Development/2.0', 'connection': 'close'}.
Body: ''.
Extra info: None.
this is my custom GCS cliet class for example.
# encoding: utf-8
import cloudstorage as gcs
class mycustomgcsclient:
#...
def create(self,name,data,**options):
options['retry_params'] = gcs.RetryParams(backoff_factor=1.1)
if not options.get('content_type'):
options['content_type'] = 'octet-stream'
if isintance(name,unicode):
name = name.encode('utf-8')
path = '/mybucketname/%s' % name
try:
with gcs.open(path,'w',**options) as f:
f.write(data)
return True
except Exception as e:
logging.exception(e)
return False
if __name__=='__main__':
data = 'some data ...¥n'
filename = 'somedir/%s' % u'sample.txt'
mycustomgcsclient().create(filename,data) # no error occured.
filename = 'somedir/%s' % u'あいうえお.txt'
mycustomgcsclient().create(filename,data) # error occured in this line.
I have caught an error above when only using a multibytes filename.
I have not caught any error when using a ascii's filename.
I am using a "GCS Client Library (Python)" given by on https://developers.google.com/appengine/docs/python/googlecloudstorageclient/download.
My dev_appserver.py's version is Development SDK 1.9.6, and this is working on MacOS X Marve..(? forgotten).
Is there some solutions?
I think you may need to call
urllib.quote()
on the name after encoding it to utf8.Here is a modified version of the GCS Python demo (http://appengine-gcs-client.googlecode.com/svn/trunk/python/demo/main.py) that works properly using a multibyte filename: