Mount S3 (s3fs) on EC2 with dynamic files - Persistent Public Permission

前端 未结 2 1105
春和景丽
春和景丽 2021-01-14 06:52

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 p

2条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-14 07:26

    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
        )
    ));
    

    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!

提交回复
热议问题