使用动态文件在EC2上挂载S3(s3fs)-持久公共权限 [英] Mount S3 (s3fs) on EC2 with dynamic files - Persistent Public Permission
问题描述
使用S3FS和FUSE将S3存储桶安装到AWS EC2实例时,我遇到了一个问题,即正在更新我的S3文件,但是新文件未获得适当的许可。
Using S3FS and FUSE to mount a S3 bucket to an AWS EC2 instance, I encountered a problem whereby my S3 files are being updated, but the new files doesn't adopt the proper permission.
新文件具有的ACL权限是 ---------而不是 rw-r--r--。我确保通过以下方式正确安装存储桶:
The ACL rights that the new files had were "---------" instead of "rw-r--r--". I've ensured that the bucket is mounted properly by:
sudo /usr/bin/s3fs -o allow_other -o default_acl="public-read" [bucketname] [mountpoint]
并在/ etc / fstab中创建自动挂载:
and creating an automount in /etc/fstab:
s3fs#[bucketname] [mountpoint] fuse defaults,noatime,allow_other,uid=1000,gid=1000,use_cache=/tmp,default_acl=public-read 0 0
和/ etc / passwd-s3fs中的密码文件
and password file in /etc/passwd-s3fs with the right permissions.
我的设置是Ubuntu 13.04,PHP5,AWS SDK。
My setup is Ubuntu 13.04, PHP5, AWS SDK.
经过2天的实验,我在下面提供的答案中找到了针对PHP的解决方案。
After 2 days of experimenting, I've found a solution (for php) in the provided answer below.
推荐答案
在我的php脚本中,将文件PUT到S3使用适用于PHP的AWK SDK,我必须添加元数据,如下所示,这可以解决问题:
In my php script that PUT files to S3 using AWK SDK for PHP, I had to add in the meta data, as shown below, which did the trick:
$response = $s3->create_object('bucketname', 'mountpoint/'.$filename, array(
'body' => $json_data,
'contentType' => 'application/json',
'acl' => AmazonS3::ACL_PUBLIC,
'meta' => array(
'mode' => '33188', // x-amz-meta-mode
)
));
模式 33188定义了权限 rw-r--r--而不是 S3存储桶中的------------(但仅反映在EC2安装的文件夹中),后来由EC2安装的驱动器继承。
The mode "33188" defined the permissions "rw-r--r--" instead of "---------" in S3 bucket (but reflected only in the EC2 mounted folder), which was later inherited by the EC2 mounted drive.
希望这对某人有帮助。让我知道!
Hope this helps someone. Let me know!
这篇关于使用动态文件在EC2上挂载S3(s3fs)-持久公共权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!