如何处理烧瓶上的静态/媒体文件许可? [英] How to handle static/media file permission on flask?

查看:158
本文介绍了如何处理烧瓶上的静态/媒体文件许可?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个应用程序,其中媒体文件(由用户上传的文件,而不是css / js)由子域上的另一个服务器静态提供,例如: media.example.com/path /to/image.jpg 。我怎样才能限制访问的图像,以便只有特定的人谁已经登录,并有权限可以看到他们?

请注意页面上的图像是显示正在工作,但我想进一步限制访问图像本身,所以图像网址不能共享。



谢谢

解决方案

通过Flask而不是Web服务器处理您的图像,将其视为具有权限的任何其他网址。 Nginx显然是更好的选择来服务你的静态文件,但它不会与Flask集成。


I've created an application in which media files(files that are uploaded by users, not css/js) are served statically by another server on the subdomain like: media.example.com/path/to/image.jpg. How can I limit access to the images so that only certain people who are logged in and have permission can see them?

Please note that persmissions on page in which an image is displayed are working but I want to further limit access to the images themselves so image urls can't be shared.

Thanks

解决方案

Serve your image through Flask instead of your web server, treat it like any other url with permissions. Nginx is obviously a much better choice to serve your static files but it won't integrate with Flask.

这篇关于如何处理烧瓶上的静态/媒体文件许可?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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