curl: (56) 在GCP SDK中失败,但在虚拟机中没有。

问题描述 投票:0回答:1

目标

我想从一个在线数据库中下载一个大的zip文件到GCP bucket中。gsutil cp - "gs:

我试过的方法

我试着用几种不同的方法来完成上述工作。首先,我在GCP上的云端shell中尝试了以下命令。curl -O https://website/file.zip | gsutil cp - gs://bucke/file.zip没有成功,所以我在Windows电脑上的Google Cloud SDK shell中试了一下,得到了以下输出(cURL不含gsutil也会得到同样的输出)。

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  1 43.5G    1  735M    0     0   239k      0 52:55:07  0:52:23 52:02:44     0
curl: (56) Send failure: Connection was reset
'count' is not recognized as an internal or external command,
operable program or batch file.
Copying from <STDIN>...
/ [1 files][    0.0 B/    0.0 B]
Operation completed over 1 objects.

最后,我在Ubuntu虚拟机中试了一下cURL命令,结果正常。唯一的问题是,我没有足够的权限使用gsutil将文件上传到GCP bucket中(上传其他文件时,我得到一个403错误)。

推测的问题

我注意到不是只有我一个人有类似的问题,所以我研究了几个建议的解决方案(1,2,3), 这个 解决方案中提到,这一定是我的系统出现了一些问题,因为它在虚拟机中工作正常。当我尝试从不同的网站下载&从我的计算机上从云SDK shell上传一个小文件(使用相同的命令),它可以正常工作。从同一个网站下载一个更小的zip文件不会像之前那样返回错误,而是这样。

 % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 12.2M  100 12.2M    0     0   313k      0  0:00:40  0:00:40 --:--:--  354k

'count' is not recognized as an internal or external command,
operable program or batch file.
Copying from <STDIN>...
/ [1 files][    0.0 B/    0.0 B]      0.0 B/s
Operation completed over 1 objects.

当我从GCP bucket下载压缩文件时,它似乎是一个无效的压缩文件。

所以显然问题出在网站与我电脑的连接上。(因为同一网站其他电脑能用,同一电脑其他网站也能用),我猜测这可能是防火墙的问题,但我对这方面的知识很有限。谁能帮我从这里继续排除故障?我该如何弄清楚是否真的是防火墙问题,如何解决这个问题(或者找到相关资料,如何一步步解决)?

任何帮助都非常感谢!

curl google-cloud-platform sdk gsutil google-cloud-shell
1个回答
0
投票

移除 -O 命令中的文件。你的文件被保存在本地(检查本地目录中的file.zip),而不是用管道传送到gsutil。

curl https://website/file.zip | gsutil cp - gs://bucke/file.zip

-O curl的flag强制输出到文件,而不是STDOUT,所以管道中的下一条命令(gsutil)什么也不会收到。


0
投票

当你使用流式上传大文件时,建议先将数据写入本地文件[1]。所以你可以试试

首先,下载到本地文件。

curl -O URL

其次将文件上传到你的桶里[2]。

gsutil cp file gs:/bucket

另外,也许你可以用一个小文件来测试一下。

curl "http:/nginx.orgdownloadnginx-1.17.10.zip。" /buckenginx-1.17.10.zip"

[1] https:/cloud.google.comstoragedocsgsutilcommandscp#streaming-transfer。

[2] https:/cloud.google.comstoragedocsgsutilcommandscp#copying-to-from-subdirectories-distributing-transfer-across-machines。

© www.soinside.com 2019 - 2024. All rights reserved.