简体   繁体   English

如何使用 django 作为后端和 nginx 下载文件

[英]How to download file using django as backend and nginx

I have a filefield in a document model from which i can upload files like this我在文档 model 中有一个文件字段,我可以从中上传这样的文件

document=models.FileField(max_length=350 ,validators=[FileExtensionValidator(extensions)])

uploading is working good, now i want to implement download feature for the frontend, but only those files which are uploaded by the user.上传工作良好,现在我想为前端实现下载功能,但仅限于用户上传的那些文件。

using url method is think less secure,使用 url 方法认为不太安全,

another way i saw is creating download function in the views,我看到的另一种方式是在视图中创建下载 function,

and another i saw using nginx i can implement.另一个我看到使用 nginx 我可以实现。

Kindly guide me which method is best, and what steps to take to implement the download feature, and will i need docker too if i am using nginx?请指导我哪种方法最好,以及要采取哪些步骤来实现下载功能,如果我使用 nginx,我是否也需要 docker?

i have found another way, there is a library which makes everything alot easier named as django_downloadview.我找到了另一种方法,有一个名为 django_downloadview 的库可以让一切变得更容易。 it solved the problem for now lets see what happens in the future.它现在解决了这个问题,让我们看看未来会发生什么。

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

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