如何将烧瓶静态指向digitalocean空间
我正在使用HTML页面中的URL_来访问和显示静态图像。我希望将烧瓶静态连接到digitalocean空间,而不是AWS S3,为在这个问题中解释了。
我希望在连接到数字海洋空间后,url_for将替换:
原始路径:static/folder1/image.jpg到
数字海洋空间:https:// https:// {do_space_name} .sgp1.digigitaloceanspaces .com/static/folder1/image.jpg
我尝试过 flask noreferrer“> flask-s3 sdk - 假设“空格是S3兼容的对象存储服务”
from flask_s3 import FlaskS3
app.config['AWS_ACCESS_KEY_ID'] = 'aaaaaaaaaaaaaa'
app.config['AWS_SECRET_ACCESS_KEY'] = 'xxxxxxxxxxxxxxxxxxx'
app.config['FLASKS3_BUCKET_DOMAIN'] = 'sgp1.digitaloceanspaces.com'
app.config['FLASKS3_BUCKET_NAME'] = 'do_space_name'
s3 = FlaskS3(app)
会生成并替换我预期的路径,但是在HTML中,它显示了错误403-(禁止)
我对Digitalocean Space的设置如下:
文件列表:启用
文件列表(任何人都可以列出此空间的内容)CDN(内容
交付网络):禁用CORS配置:未设置
甚至尝试这样的事情也很有意义吗?是否有其他可以帮助实现这一目标的方法或SDK?
I am using url_for in my html pages to access and display static images. I wish to connect flask static to digitalocean spaces instead of AWS S3 as explained in this question.
I expect that after connecting to digital ocean spaces, the url_for would replace:
original path: static/folder1/image.JPG to
digital ocean spaces: https://{do_space_name}.sgp1.digitaloceanspaces.com/static/folder1/image.JPG
I have tried Flask-S3 SDK - assuming "Spaces is an S3-compatible object storage service"
from flask_s3 import FlaskS3
app.config['AWS_ACCESS_KEY_ID'] = 'aaaaaaaaaaaaaa'
app.config['AWS_SECRET_ACCESS_KEY'] = 'xxxxxxxxxxxxxxxxxxx'
app.config['FLASKS3_BUCKET_DOMAIN'] = 'sgp1.digitaloceanspaces.com'
app.config['FLASKS3_BUCKET_NAME'] = 'do_space_name'
s3 = FlaskS3(app)
This generates and replaces the path I expected, but in html it shows error 403 - (Forbidden)
My setting for digitalocean spaces are as below:
File Listing: Enable
File Listing (Anyone can list the contents of this Space) CDN (Content
Delivery Network): disables CORS Configurations: not set
Does it make sense to even attempt something like this? Is there any alternative approach or SDK that can help achieve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明 - 这是值得几天的愚蠢之处……但这没关系。
回答自己,以防万一有人偶然发现:
1:禁止错误,因为我在do空间中的静态文件没有公开标记为公开:)
2:2:我不在(显然是错误的)印象,如果我给出访问键和秘密键,为配置然后,我不必担心文件级别的权限
3:但是事实证明,即使没有这些,您也可以连接到执行空间,因此重要的是文件级别访问。
4:要使HTML网页访问静态文件,然后需要公开。
Turns out - this is worth couple of days worth of stupidity...but that's ok.
Answering myself just in case someone stumbles upon:
1: Forbidden error is thrown because my static files in DO spaces was not marked as Public :)
2: I was under (obviously wrong) impression that if I give access key and secret key as config then I need not worry about file level permission
3: But turns out that you can connect to DO spaces even without these, hence what matters is the file level access.
4: For html webpage to access static files, then need to be public.