【问题标题】:curl: (56) Failure in GCP SDK, but not in VMcurl: (56) GCP SDK 失败,但 VM 没有
【发布时间】:2020-08-06 15:14:22
【问题描述】:

目标

我想从在线数据库中将一个大型 zip 文件下载到 GCP 存储桶中。当谈到 GCP 和在终端工作时,我不是很技术,我偶然发现了一些我无法解决的问题。

我尝试过的

我尝试以几种不同的方式完成上述操作。首先,我在 GCP 上的云 shell 中尝试了以下命令:curl -O https://website/file.zip | gsutil cp - gs://bucke/file.zip,没有用,所以我在 Windows 计算机上的 Google Cloud SDK shell 中尝试了它,我得到了以下输出(没有 gsutil 的 cURL 给出了相同的输出) :

  % 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)VM 中尝试了 cURL 命令,它运行良好。唯一的问题是我没有足够的权限使用 gsutil 将文件上传到 GCP 存储桶(上传其他文件时也会出现 403 错误)。

假设问题

我注意到我不是唯一一个有类似问题的人,所以我研究了几个建议的解决方案 (1,2,3),this 解决方案提到它一定是一些我的系统出现问题,因为它在 VM 中运行良好。当我尝试从另一个网站从我的计算机(使用相同的命令)上的 cloud 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 存储桶下载 zip 文件时,它似乎是一个无效的 zip 文件。

显然,问题在于网站与我的计算机的连接性。 (因为具有相同网站的其他计算机可以工作,而具有相同计算机的其他网站也可以工作),我猜这可能是防火墙问题,但我对此的了解非常有限。有人可以帮我从这里继续故障排除吗?如何确定是否确实是防火墙问题,以及如何解决此问题(或查找有关如何逐步执行此操作的信息)?

非常感谢任何帮助!

【问题讨论】:

    标签: curl google-cloud-platform sdk gsutil google-cloud-shell


    【解决方案1】:

    从 curl 命令中删除 -O。您的文件正在本地保存(检查本地目录中的 file.zip),而不是通过管道传输到 gsutil。

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

    -O curl 标志强制输出到文件,而不是 STDOUT,因此管道中的下一个命令 (gsutil) 什么也不接收。

    【讨论】:

      【解决方案2】:

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

      首先,下载到本地文件。

      curl -O 网址

      第二次将文件上传到您的存储桶 [2]

      gsutil cp 文件 gs://bucket

      另外,也许您可​​以尝试使用小文件进行测试:

      curl "http://nginx.org/download/nginx-1.17.10.zip" | gsutil cp-“gs://bucke/nginx-1.17.10.zip”

      [1]https://cloud.google.com/storage/docs/gsutil/commands/cp#streaming-transfers

      [2]https://cloud.google.com/storage/docs/gsutil/commands/cp#copying-tofrom-subdirectories-distributing-transfers-across-machines

      【讨论】:

        猜你喜欢
        • 2012-04-14
        • 2022-11-04
        • 1970-01-01
        • 2014-02-19
        • 1970-01-01
        • 2014-06-20
        • 1970-01-01
        • 1970-01-01
        • 2013-10-23
        相关资源
        最近更新 更多