简体   繁体   English

公开通过SMTP上传到S3的文件

[英]Make Files Uploaded by SMTP to S3 Public

I'm using cloudmailin.com to upload attachments from emails to an S3 bucket. 我正在使用cloudmailin.com将附件从电子邮件上传到S3存储桶。 The bucket itself has public settings, but I am unable to access the uploaded data from the data's link as S3 apparently doesn't make files uploaded by other users public. 存储桶本身具有公共设置,但是我无法从数据链接访问上传的数据,因为S3显然不会将其他用户上传的文件设为公开。

Currently, I'm using the bucket policy below, which is supposed to make the bucket's contents public: 目前,我正在使用下面的存储桶策略,该策略应将存储桶的内容公开:

{
    "Version": "2008-10-17",
    "Statement": [
        {
            "Sid": "AllowPublicRead",
            "Effect": "Allow",
            "Principal": {
                "AWS": "*"
            },
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::mjkaufer_cloudmailin/*"
        }
    ]
}

This only works if I manually upload something to S3. 仅当我手动将内容上传到S3时,此方法才有效。 If I manually upload something, I can view the link and it can open in a new window. 如果我手动上传内容,则可以查看该链接,它可以在新窗口中打开。 But if it's uploaded from cloudmailin, I'm unable to view the file. 但是,如果它是从cloudmailin上传的,则无法查看该文件。

Does anybody know a workaround? 有人知道解决方法吗? I just need to make it such that files uploaded to a bucket by a 3rd party (cloudmailin) are visible. 我只需要使其可见即可显示由第三方(cloudmailin)上传到存储桶的文件。

Thanks. 谢谢。

The problem is that as CloudMailin uploads your attachments to AWS S3 it needs to set the ACL permissions on them. 问题在于,当CloudMailin将您的附件上传到AWS S3时,需要为其设置ACL权限。 AWS offers a couple of 'canned permissions' for this. AWS为此提供了两个“固定权限”。 The only two that are really of interest to CloudMailin are the following: 以下是CloudMailin真正感兴趣的仅有两个:

  • bucket-owner-full-control - this is what you're currently set to, it grants the bucket owner full control over the uploaded attachment. bucket-owner-full-control这是您当前设置的状态,它授予存储桶所有者对上载附件的完全控制权。
  • public-read - this will grant you full control as the bucket owner but will also set read only privileges for everyone. public-read -这将授予您作为存储桶所有者的完全控制权,但还将为所有人设置只读权限。

If you log into CloudMailin head to your address list and click 'manage' on the address you need to edit. 如果您登录CloudMailin ,请转到您的地址列表,然后在您需要编辑的地址上单击“管理”。 Then head to 'Edit Attachment Store' and select 'Public Read' then CloudMailin will set this canned policy as the email attachments are uploaded to S3. 然后转到“编辑附件存储”并选择“公共阅读”,然后将电子邮件附件上传到S3时,CloudMailin会设置此罐头策略。

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

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