简体   繁体   English

如何直接在 s3 上解压 s3 上的文件?

[英]How to untar a file on s3 directly on s3?

I have a 10G file.tar file on s3, I want to decompress that file and keep the unzipped files on s3.我在 s3 上有一个 10G file.tar 文件,我想解压缩该文件并将解压缩的文件保留在 s3 上。

Is there a simple command I can run against s3?有没有我可以针对 s3 运行的简单命令?

Or do I have to unzip the file myself locally, and upload the individual files back to s3 myself?还是我必须自己在本地解压缩文件,然后自己将各个文件上传回 s3?

Thanks谢谢

You can do this from the Amazon CLI, or the new Amazon CloudShell , with a command like您可以从 Amazon CLI 或新的Amazon CloudShell执行此操作,使用如下命令

aws s3 cp s3://bucket/data.tar.gz - | tar -xz --to-command='aws s3 cp - s3://bucket/$TAR_REALNAME'

Note all those dangling '-' chars are important for piping to stdout/stdin请注意,所有那些悬挂的“-”字符对于通过管道传输到标准输出/标准输入很重要

There is no command to manipulate file contents on Amazon S3.在 Amazon S3 上没有操作文件内容的命令。

You will need to download the file, untar/unzip it, then upload the content to S3.您需要下载该文件,对其进行解压/解压缩,然后将内容上传到 S3。

This will be done the most quickly from an Amazon EC2 instance in the same region as the bucket.这将从与存储桶位于同一区域的 Amazon EC2 实例中以最快的速度完成。 You could potentially write an AWS Lambda function to do this too, but beware of the 500MB /tmp disk space limit.您也可以编写一个 AWS Lambda 函数来执行此操作,但要注意 500MB /tmp磁盘空间限制。

You can, however, mount S3 bucket on EC2 as S3FS.但是,您可以将 S3 存储桶作为 S3FS 安装在 EC2 上。

Here is the link with more detail on how to mount: https://cloudkul.com/blog/mounting-s3-bucket-linux-ec2-instance/以下是有关如何安装的更多详细信息的链接: https ://cloudkul.com/blog/mounting-s3-bucket-linux-ec2-instance/

Once mounted you can read and write files to s3 just like you do in local disk.安装后,您可以像在本地磁盘中一样将文件读写到 s3。

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

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