如何将上传文件保存到其他服务器 [英] How to save upload files to another server

查看:198
本文介绍了如何将上传文件保存到其他服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Django。现在我需要将用户上传的文件保存到另一个服务器上,该服务器不是服务于django应用程序的服务器。该文件将被保存到文件系统而不是数据库。有人可以告诉我如何做到这一点吗?解决方案

默认的Django行为是保存文件系统上的文件,而不是数据库本身) 。

你有几个选择如何做到这一点,最简单的就是从你的其他机器上导出一个文件系统,并用django应用程序挂载到机器上。

对于文件系统导出,您可以使用NFS,MogileFS或GlusterFS(我正在使用)或更多:)。第二种选择是利用现有的Django机制 //docs.djangoproject.com/en/dev/ref/files/storage/rel =nofollow> StogareAPI 。已经有已经提供不同的存储备份可以使用,并可能对您有所帮助(例如ftp)。

I'm currently using django. And now I need to save a file uploaded by a user to another server which is not the one that serves the django application. The file will be saved to file system not the database. Could somebody tell me how to do this?

解决方案

Default Django behavior is to save file on the filesystem, not the database itself).

You have several options how to do this, the simplest one is to have a filesystem exported from you "other" machine and mounted on the machine with the django application.

For the filesystem export you can use NFS, MogileFS or GlusterFS (which I'm using) or many more :). If you do not need real-time save&serve, simple rsync may be an option too.

Second option is to utilize existing django mechanisms StogareAPI. There are already available different storage backeds you can use and may be helpful for you (e.g. ftp).

这篇关于如何将上传文件保存到其他服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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