gsutil fails to upload file with “codec can't

2019-08-18 05:38发布

I'm uploading a static website to cloud storage using the command

gsutil cp -v -R -c * gs://www.gennadiy-dolzhenko.ru

mid process it fails with the following output

...SNIP...
Copying file://tourism_studies/models/articles/54-moskva/slideshow/resized/sk576.jpg [Content-Type=image/jpeg]...
Created: gs://www.gennadiy-dolzhenko.ru/tourism_studies/models/articles/54-moskva/slideshow/resized/sk576.jpg#1403352412336000
Copying file://tourism_studies/models/articles/54-moskva/slideshow/resized/7.jpg [Content-Type=image/jpeg]...
Created: gs://www.gennadiy-dolzhenko.ru/tourism_studies/models/articles/54-moskva/slideshow/resized/7.jpg#1403352412725000
'ascii' codec can't decode byte 0xdd in position 1: ordinal not in range(128)

Its unclear which file is faulty and -c flag doesn't make the tool continue upload as described. How can I determine what is causing the error or at least make the tool upload as many files as possible?

UPDATE: using the -D switch I was able to trace it down to the following error

Comparing local vs cloud md5-checksum for tourism_studies/models/articles/54-moskva/slideshow/resized/7.jpg. (O8RgYfpRe8ylUbJh4UPfWg==/O8RgYfpRe8ylUbJh4UPfWg==)
Created: gs://www.gennadiy-dolzhenko.ru/tourism_studies/models/articles/54-moskva/slideshow/resized/7.jpg#1403367381161000
'ascii' codec can't decode byte 0xdd in position 1: ordinal not in range(128)


Encountered exception while copying:
Traceback (most recent call last):
  File "/home/evgeniy/gsutil/gslib/command.py", line 1105, in _SequentialApply
    args = args_iterator.next()
  File "/home/evgeniy/gsutil/gslib/plurality_checkable_iterator.py", line 57, in _PopulateHead
    e = self.base_iterator.next()
  File "/home/evgeniy/gsutil/gslib/name_expansion.py", line 294, in __iter__
    for (names_container, blr) in post_step3_iter:
  File "/home/evgeniy/gsutil/gslib/plurality_checkable_iterator.py", line 57, in _PopulateHead
    e = self.base_iterator.next()
  File "/home/evgeniy/gsutil/gslib/name_expansion.py", line 521, in __iter__
    for (names_container, blr) in self.tuple_iter:
  File "/home/evgeniy/gsutil/gslib/plurality_checkable_iterator.py", line 57, in _PopulateHead
    e = self.base_iterator.next()
  File "/home/evgeniy/gsutil/gslib/name_expansion.py", line 580, in __iter__
    for exp_blr in implicit_subdir_iterator:
  File "/home/evgeniy/gsutil/gslib/plurality_checkable_iterator.py", line 57, in _PopulateHead
    e = self.base_iterator.next()
  File "/home/evgeniy/gsutil/gslib/wildcard_iterator.py", line 560, in IterAll
    for bucket_listing_ref in self.__iter__():
  File "/home/evgeniy/gsutil/gslib/wildcard_iterator.py", line 519, in __iter__
    for filepath in filepaths:
  File "/home/evgeniy/gsutil/gslib/wildcard_iterator.py", line 530, in _IterDir
    for dirpath, unused_dirnames, filenames in os.walk(directory):
  File "/usr/lib/python2.7/os.py", line 294, in walk
    for x in walk(new_path, topdown, onerror, followlinks):
  File "/usr/lib/python2.7/os.py", line 294, in walk
    for x in walk(new_path, topdown, onerror, followlinks):
  File "/usr/lib/python2.7/os.py", line 294, in walk
    for x in walk(new_path, topdown, onerror, followlinks):
  File "/usr/lib/python2.7/os.py", line 294, in walk
    for x in walk(new_path, topdown, onerror, followlinks):
  File "/usr/lib/python2.7/os.py", line 294, in walk
    for x in walk(new_path, topdown, onerror, followlinks):
  File "/usr/lib/python2.7/os.py", line 284, in walk
    if isdir(join(top, name)):
  File "/usr/lib/python2.7/posixpath.py", line 80, in join
    path += '/' + b
UnicodeDecodeError: 'ascii' codec can't decode byte 0xdd in position 1: ordinal not in range(128)

2条回答
迷人小祖宗
2楼-- · 2019-08-18 05:42

I am also having problems getting the following command to work:

gsutil mv "台北.html" gs://my.bucket.com

even

gsutil mv * gs://mybucket.com

won't work and (I guess phyton?) always tells me:

Failure: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)

But what works is, renaming the local file to a generated name and doing the following: gsutil mv "generatedName.html" "gs://my.bucket.com/台北.html"

I have read on another stackoverflow question that it might be reltated?

查看更多
神经病院院长
3楼-- · 2019-08-18 05:47

The problem here was a file name containing invalid Unicode chars. We have changed gsutil to provide a more helpful error message for this case. This change will be included in gsutil 4.4.

查看更多
登录 后发表回答