如何传输AWS S3和EC2 AWS之间的文件 [英] How to transfer files between AWS s3 and AWS ec2

查看:348
本文介绍了如何传输AWS S3和EC2 AWS之间的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用AWS EC2实例。

I am using AWS ec2 instance.

在这种情况下,我得到的一些文件。

On this instance i am resulting some files.

这些操作是由用户数据完成的。

These operations are done by user data.

现在我想通过写code。在用户数据本身存储在S3上的那些文件。

Now i want to store those files on s3 by writing code in User data itself.

所以,我怎么能存储在S3上这些文件?

So how can i store those files on s3?

有任何教程就可以了?

推荐答案

有多种方式将文件发送到S3。我列出他们下面一起安装和文档有关的地方。

There are a number of ways to send files to S3. I've listed them below along with installation and documentation where relevant.

  • S3CMD :( http://s3tools.org/s3cmd )您可以安装此在Debian / Ubuntu的轻松通过apt-get安装s3cmd,然后运行命令行。你可以纳入一个bash脚本或程序这一点。

  • S3CMD: (http://s3tools.org/s3cmd) You can install this on debian/ubuntu easily via apt-get install s3cmd, then run from command line. You could incorporate this into a bash script or your program.

S3FS :(<一href="http://www.pophams.com/blog/howto-setups3fsonubuntu1104x64">http://www.pophams.com/blog/howto-setups3fsonubuntu1104x64和<一href="https://$c$c.google.com/p/s3fs/wiki/InstallationNotes">https://$c$c.google.com/p/s3fs/wiki/InstallationNotes) ...这挂载的S3存储,因此它看起来就像一个本地磁盘。这需要一些更多的努力来建立,但一旦磁盘被安装,你不需要做任何特别的事情中的文件的斗。

S3FS: (http://www.pophams.com/blog/howto-setups3fsonubuntu1104x64 and https://code.google.com/p/s3fs/wiki/InstallationNotes) ... This mounts an s3 bucket, so that it looks just like a local disk. It takes a little more effort to setup, but once the disk is mounted, you don't need to do anything special to get the files in your bucket.

如果您使用的CMS(允许使用Drupal作为一个例子),你可能拥有的使用模块来处理你的水桶如的http://drupal.org/project/storage_api

If you use a CMS (lets use Drupal as an example) you may have the option of using a module to handle access to your bucket eg http://drupal.org/project/storage_api

最后,你可以使用编程语言实现,以处理所有的逻辑自己,为PHP你可以启动该<一href="http://undesigned.org.za/2007/10/22/amazon-s3-php-class">http://undesigned.org.za/2007/10/22/amazon-s3-php-class看看这里的文件<一个href="http://undesigned.org.za/2007/10/22/amazon-s3-php-class/documentation">http://undesigned.org.za/2007/10/22/amazon-s3-php-class/documentation

Finally, you can use programming language implementations to handle all the logical yourself, for PHP you can start with this http://undesigned.org.za/2007/10/22/amazon-s3-php-class and see documentation here http://undesigned.org.za/2007/10/22/amazon-s3-php-class/documentation

PHP实现的一个例子:

An example of the PHP implementation:

<?php

    // Simple PUT:
    if (S3::putObject(S3::inputFile($file), $bucket, $uri, S3::ACL_PRIVATE)) {
        echo "File uploaded.";
    } else {
        echo "Failed to upload file.";
    }

?>

s3cmd的一个例子:

An example of s3cmd:

s3cmd put my.file s3://bucket-url/my.file

修改

另一种选择值得一提的是AWS CLI http://aws.amazon.com/cli/ 这是广泛可获得的,例如它已经包含在AmazonLinux并且可以通过Python(其上安装了许多系统包括Linux和视窗)被下载。

Edit

Another option worth mention is the AWS CLI http://aws.amazon.com/cli/ This is widely available, for example it's already included on AmazonLinux and can be downloaded via Python (which is installed on many systems including linux and windows).

<一个href="http://docs.aws.amazon.com/cli/latest/reference/s3/index.html">http://docs.aws.amazon.com/cli/latest/reference/s3/index.html

可用命令,CP LS MB MV RB RM同步网站

Available commands, cp ls mb mv rb rm sync website

<一个href="http://docs.aws.amazon.com/cli/latest/reference/s3api/index.html">http://docs.aws.amazon.com/cli/latest/reference/s3api/index.html与S3交互

这篇关于如何传输AWS S3和EC2 AWS之间的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆