简体   繁体   中英

How to pipe input to gsutil cp from stdin?

I am looking for a way to pipe the data into gsutil cp:

echo '<html>foobar</html>' | gsutil cp --stdin gs://my-bucket/foo

the -I option is for reading filepaths, not the data.. gsutil help cp says:

https://gist.github.com/ORESoftware/566d9c3d00e3858c1161ae9b741fc07e

So yeah I am looking for a way to send files to GS via stdin.

Looks like it works using - like so:

echo '<html>foobar</html>' | gsutil cp - gs://my-bucket/foo

in my opinion, a --stdin flag would be more explicit and preferred.

From the docs :

You can use the -I option with stdin to specify a list of URLs to copy, one per line. This allows you to use gsutil in a pipeline to upload or download objects as generated by a program:

cat filelist | gsutil -m cp -I gs://my-bucket 

or:

cat filelist | gsutil -m cp -I ./download_dir 

where the output of cat filelist is a list of files, cloud URLs, and wildcards of files and cloud URLs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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