我使用了gsutil rsync
,没有-d
参数,即使没有任何参数,但我仍然有ResumableUploadAbortException: 403 abc@xyz.iam.gserviceaccount.com does not have storage.objects.delete access
。
我想使用Google计算引擎上的gsutil rsync
创建一个仅用于将文件上传到Google云存储的应用程序。
我已经添加了阅读和列出的权限,
因为我不希望应用程序删除存储桶中的任何文件,所以我没有授予storage.objects.delete
的权限。
是否有任何参数可以使用gsutil rsync
命令而不必授予删除文件的权限?
我想使用rsync
,因为我必须传输千兆字节的文件。
谢谢。
[编辑] 添加其他信息并进行调试:
我想添加其他信息, 此应用程序以cron的身份运行,会上传时间戳生成的文件名,因此每次执行时都会有所不同。
实际上,上传过程有效,文件已上传到存储桶,但最后还是得到ResumableUploadAbortException
。
所以我运行gsutil -D rsync
进行调试:
DEBUG: Exception stack trace:
Traceback (most recent call last):
File "/usr/lib64/google-cloud-sdk/platform/gsutil/gslib/__main__.py", line 590, in _RunNamedCommandAndHandleExceptions
user_project=user_project)
File "/usr/lib64/google-cloud-sdk/platform/gsutil/gslib/command_runner.py", line 372, in RunNamedCommand
return_code = command_inst.RunCommand()
File "/usr/lib64/google-cloud-sdk/platform/gsutil/gslib/commands/rsync.py", line 1546, in RunCommand
fail_on_error=True, seek_ahead_iterator=seek_ahead_iterator)
File "/usr/lib64/google-cloud-sdk/platform/gsutil/gslib/command.py", line 1420, in Apply
arg_checker, should_return_results, fail_on_error)
File "/usr/lib64/google-cloud-sdk/platform/gsutil/gslib/command.py", line 1491, in _SequentialApply
worker_thread.PerformTask(task, self)
File "/usr/lib64/google-cloud-sdk/platform/gsutil/gslib/command.py", line 2157, in PerformTask
results = task.func(cls, task.args, thread_state=self.thread_gsutil_api)
File "/usr/lib64/google-cloud-sdk/platform/gsutil/gslib/commands/rsync.py", line 1337, in _RsyncFunc
gzip_exts=cls.gzip_exts, preserve_posix=cls.preserve_posix_attrs)
File "/usr/lib64/google-cloud-sdk/platform/gsutil/gslib/utils/copy_helper.py", line 3520, in PerformCopy
allow_splitting=allow_splitting, gzip_encoded=gzip_encoded)
File "/usr/lib64/google-cloud-sdk/platform/gsutil/gslib/utils/copy_helper.py", line 2026, in _UploadFileToObject
parallel_composite_upload, logger)
File "/usr/lib64/google-cloud-sdk/platform/gsutil/gslib/utils/copy_helper.py", line 1877, in _DelegateUploadFileToObject
elapsed_time, uploaded_object = upload_delegate()
File "/usr/lib64/google-cloud-sdk/platform/gsutil/gslib/utils/copy_helper.py", line 2015, in CallResumableUpload
is_component=is_component, gzip_encoded=gzip_encoded_file)
File "/usr/lib64/google-cloud-sdk/platform/gsutil/gslib/utils/copy_helper.py", line 1687, in _UploadFileToObjectResumable
progress_callback=progress_callback, gzip_encoded=gzip_encoded)
File "/usr/lib64/google-cloud-sdk/platform/gsutil/gslib/cloud_api_delegator.py", line 315, in UploadObjectResumable
gzip_encoded=gzip_encoded)
File "/usr/lib64/google-cloud-sdk/platform/gsutil/gslib/gcs_json_api.py", line 1415, in UploadObjectResumable
gzip_encoded=gzip_encoded)
File "/usr/lib64/google-cloud-sdk/platform/gsutil/gslib/gcs_json_api.py", line 1242, in _UploadObject
additional_headers, progress_callback, gzip_encoded)
File "/usr/lib64/google-cloud-sdk/platform/gsutil/gslib/gcs_json_api.py", line 1371, in _PerformResumableUpload
raise resumable_ex
ResumableUploadAbortException: ResumableUploadAbortException: 403 abc@xyz.iam.gserviceaccount.com does not have storage.objects.delete access to bucket/filename
答案 0 :(得分:2)
如果我不得不猜测,您正在尝试覆盖现有对象。这将删除现有对象,将其替换为另一个同名对象。
一个替代方案可能是gsutil cp -n
,它将不会覆盖目标位置上的现有文件。但是,如果您希望能够覆盖对象,则需要删除权限。
如以下注释中所述,这也可能是由于启用了并行复合上传(在gsutil尝试删除组件对象的时候)导致的。可以通过在Boto文件中设置parallel_composite_upload_threshold=0
或在命令中内联设置来禁用此行为,例如gsutil -o "GSUtil:parallel_composite_upload_threshold=0" ...
。