使用python和boto将s3中的文件公开 [英] Make a file in s3 public using python and boto

查看:109
本文介绍了使用python和boto将s3中的文件公开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我下面有一个Thins链接,当我尝试访问它时,它会出现一个xml文件,上面写着访问被拒绝".

I have thins link below, and when I try to acess it it appears an xml file saying "Acess denied".

我需要进入aws管理控制台,并将此part-0000文件公开,以便可以访问它.

And I need to go to aws managment console and make this part-0000 file public so I can acess it.

您知道如何在python中使用boto来授予权限,这样我就可以访问该链接,而无需转到AWS管理控制台并公开该文件?

Do you know how can I give permissions using boto with python so I can acess this link without needed to go to aws managmet console and make the file public?

downloadLink = 'https://s3.amazonaws.com/myFolder/uploadedfiles/2015423/part-00000'

推荐答案

这应该给您一个想法:

import boto.s3
conn = boto.s3.connect_to_region('us-east-1')  # or region of choice
bucket = conn.get_bucket('myFolder')
key = bucket.lookup('uploadedfiles/2015423/part-00000')
key.set_acl('public-read')

在这种情况下,public-read是S3支持的固定ACL策略之一,并且允许任何人读取文件.

In this case, public-read is one of the canned ACL policies supported by S3 and would allow anyone to read the file.

这篇关于使用python和boto将s3中的文件公开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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