简体   繁体   English

如何将 csv 文件从 GCP 云存储桶传输到 ftp 服务器

[英]How to transfer csv files from GCP cloud storage bucket to a ftp server

We need to transfer the csv files from GCP cloud storage to a ftp server, how we can achieve this?我们需要将 csv 文件从 GCP 云存储传输到 ftp 服务器,我们如何实现?

Can we transfer this files directly to ftp with bigquery tools?我们可以使用 bigquery 工具将这些文件直接传输到 ftp 吗?

Or do we need to download it with a service and then upload to the ftp?还是需要用服务下载然后上传到ftp?

EDIT: Ah... Seems I've missed your Java tag.编辑:啊...似乎我错过了你的Java标签。 Well, if you're okay with spawning sub-processes, then the following solution should work.好吧,如果您对生成子流程没问题,那么以下解决方案应该可行。 Else, please consult the supported Java API for GCP.否则,请咨询 GCP 支持的 Java API。 As of today it's this one到今天为止是这个

If you have ssh access to your ftp server, then simply use the Google Cloud SDK:如果您可以通过 ssh 访问您的 ftp 服务器,那么只需使用 Google Cloud SDK:

gsutil cp gs://[BUCKET_NAME]/[OBJECT_NAME] [SAVE_TO_LOCAL_FTP_DIR]

Else, the following command pipes data from GCP -> Your local machine -> FTP:否则,以下命令从 GCP -> 您的本地机器 -> FTP 传输数据:

gsutil cp gs://[BUCKET_NAME]/[OBJECT_NAME] - | curl -T - ftp://user:PASS@ftp-server.com/filename.ext

The first - after [OBJECT_NAME] tells gsutil to write to STDOUT instead of an ordinary file, while the second - tells curl -T to read from STDIN .第一个-[OBJECT_NAME]告诉gsutil写入STDOUT而不是普通文件,而第二个-告诉curl -TSTDIN读取。 For the uninitiated, the |对于外行, | is a bash pipe indicating to pass STDOUT of the first program to the STDIN of the next.是一个 bash 管道,指示将第一个程序的STDOUT传递给下一个程序的STDIN

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

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