繁体   English   中英

使用 PUT 将文件上传到谷歌云时,CURL 缺少必需的 header

[英]CURL missing required header when uploading file to google cloud using PUT

我正在尝试通过运行以下命令使用 curl 在我的 docker pod 中上传文件:

curl -X PUT -H 'Content-Type: video/mp4' -H "Content-Length:12345" --upload-file ./output/file/path "SIGNED_URL"

我正在尝试使用谷歌云控制台在 pod 内运行它,但是当我这样做时,我得到了这个错误:

[1] 3205
[2] 3206
[3] 3208
[4] 3209
[5] 3210
-bash: X-Goog-Date=20220812T114055Z: command not found
-bash: X-Goog-Credential=cloudrun%project.iam.gserviceaccount.com%..._request: command not found
-bash: X-Goog-Expires=7199: command not found
-bash: X-Goog-SignedHeaders=content-type%3Bhost: command not found
-bash: X-Goog-Signature=...: command not found
[2]   Exit 127                X-Goog-Credential=cloudrun%project.iam.gserviceaccount.com%...
[3]   Exit 127                X-Goog-Date=20220812T114055Z
[4]-  Exit 127                X-Goog-Expires=7199
[5]+  Exit 127                X-Goog-SignedHeaders=content-type%3Bhost
user@cloudshell:~ (project)$ Fetching cluster endpoint and auth data.
kubeconfig entry generated for cluster-1.
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0<?xml version='1.0' encoding='UTF-8'?><Error><Code>MissingSecurityHeader</Code><Message>Your request was missing a required header.</Message><Details>x-go100  700k  100   185  100  700k    480  1816k --:--:-- --:--:-- --:--:-- 1813k

[1]+  Done                    gcloud container clusters get-credentials cluster-1 --region us-central1 --project project && kubectl exec nca1ozmnicx5-shsfx -c jobcontainer -- curl -X PUT -H 'Content-Type: video/mp4' -H "Content-Length:12345" --upload-file ./output/file/path SIGNED_URL

我看到了这个答案,但我不想使用 oauth2,因为我已经有一个签名的 url。 此外,我需要有人让我在其他选项(例如gsutil )上走上正轨,我对此有点迷茫。

我正在使用 ubuntu 图像。

编辑:如果我尝试按照本教程下载 gsutil,它会在我下载它时要求我选择一个帐户,但我无法使用它,因此我无法设置它。 在我的 pod 中设置 gsutil 可能有点麻烦。 所以我宁愿不要,除非我必须这样做。

您需要使用此处给出的命令:

curl -X PUT -H 'Content-Type: application/octet-stream' --upload-file 6e069c12-649d-4d87-9401-0d2f81a7bbff "<<SIGNEDURL>>"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM