解压 S3 文件并通过 AWS CLI 将解压文件推回 S3

000*_*004 3 amazon-web-services

使用 AWS CLI 后,您可以从 S3 解压缩文件并将解压缩的版本推回 S3 吗?

尝试以下方法,尚未成功。

unzip aws s3 cp https://aws-lake/test/test.zip
Run Code Online (Sandbox Code Playgroud)

Ano*_*ard 7

您至少需要执行三个操作:

# Download the zip file from S3, note the use of the S3 URI, not HTTPS
aws s3 cp s3://aws-lake/test/test.zip temp.zip

# Decompress the zip file into a temp directory
unzip -d temp_zip_contents temp.zip

# Sync up the contents of the temp directory to S3 prefix
aws s3 sync temp_zip_contents s3://aws-lake/test/test_contents

# And optionally, clean up the temp files and directory
# Unix:
rm -rf temp.zip temp_zip_contents
# Windows
rd /s/q temp_zip_contents
del temp.zip
Run Code Online (Sandbox Code Playgroud)

可以编写一个程序将文件下载到内存中,读取 zip 文件的内容,然后上传解压缩的各个文件,但这需要多个命令行命令。