bash 在没有 aws-cli 的情况下通过 shell 脚本上传到 S3,可能吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33112081/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Upload to S3 via shell script without aws-cli, possible?
提问by Fadi
As the title says, is it possible to upload to S3 via shell script without aws-cli-tools?
正如标题所说,是否可以在没有 aws-cli-tools 的情况下通过 shell 脚本上传到 S3?
If so, how?
如果是这样,如何?
What I'm trying to do is read from a txt file on S3 (which is public, so no authentication is required).
我想要做的是从 S3 上的 txt 文件中读取(这是公开的,因此不需要身份验证)。
But I want to be able to overwrite whatever is in the file (which is just a number).
但我希望能够覆盖文件中的任何内容(这只是一个数字)。
Thanks in advance,
提前致谢,
Fadi
法迪
回答by Mircea
Yes you can! You basically emulate the api calls the SDK would do for you through standard linux cmd utils.
是的你可以!您基本上可以通过标准的 linux cmd utils 模拟 SDK 为您执行的 api 调用。
Look at:
看着:
https://aws.amazon.com/code/Amazon-S3/943
https://aws.amazon.com/code/Amazon-S3/943
and/or
和/或
回答by sehe
I use s3cmd
which is a command line tool written in Python.
我使用的s3cmd
是用 Python 编写的命令行工具。
It uses the (restful) web APIs.
它使用(restful)Web API。
s3cmd put --recursive
s3cmd sync
s3cmd put --recursive
s3cmd sync
would be the interesting bits:
将是有趣的部分:
Synchronize a directory tree to S3
s3cmd sync LOCAL_DIR s3://BUCKET[/PREFIX] or s3://BUCKET[/PREFIX] LOCAL_DIR
将目录树同步到 S3
s3cmd 同步 LOCAL_DIR s3://BUCKET[/PREFIX] 或 s3://BUCKET[/PREFIX] LOCAL_DIR