我有一个非常简单的 Google Cloud 工作流程,即复制文件在同一个存储桶中:
main:
steps:
- list:
call: googleapis.storage.v1.objects.list
args:
bucket: "**************"
prefix: "xxx/extra_cost_commute.txt"
result: listResult
- log-files:
call: sys.log
args:
data: ${listResult}
severity: "INFO"
- copy:
call: googleapis.storage.v1.objects.copy
args:
sourceBucket: "**************"
sourceObject: "xxx/extra_cost_commute.txt"
destinationBucket: "**************"
destinationObject: "yyy/new_extra_cost_commute.txt"
result: copyResult
- log-copy:
call: sys.log
args:
data: ${copyResult}
severity: "INFO"
list
步骤正确返回对象xxx/extra_cost_commute.txt
,但copy
步骤触发404未找到异常。
HTTP server responded with error code 404
in step "copy", routine "main", line: 15
{
"body": "Not Found",
"code": 404,
"headers": {
"Alt-Svc": "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000",
"Cache-Control": "no-cache, no-store, max-age=0, must-revalidate",
"Content-Length": "9",
"Content-Type": "text/html; charset=UTF-8",
"Date": "Mon, 13 May 2024 19:42:39 GMT",
"Expires": "Mon, 01 Jan 1990 00:00:00 GMT",
"Pragma": "no-cache",
"Server": "UploadServer",
"Vary": "Origin, X-Origin",
"X-Guploader-Uploadid": ""
},
"message": "HTTP server responded with error code 404",
"tags": [
"HttpError"
]
}
为什么?我究竟做错了什么?我迷路了。
注意:我测试了通过批处理连接器在
gcr.io/google.com/cloudsdktool/google-cloud-cli:alpine
中使用 gcloud 进行复制,并且工作正常。
由于您的 sourceObject 和 DestinationObject 包含
/
,您应该对路径进行 encode 。在工作流程中,您可以使用功能 text.url\_encode
。我尝试了您的工作流程,如果您将复制步骤更改为:,它应该可以工作
copy:
call: googleapis.storage.v1.objects.copy
args:
sourceBucket: "bucket-name"
sourceObject: ${text.url_encode("xxx/extra_cost_commute.txt")}
destinationBucket: "bucket-name"
destinationObject: ${text.url_encode("yyy/new_extra_cost_commute.txt")}
result: copyResult
另外,看看这篇 GCC 帖子。