多个Django存储后端系统 [英] Multiple Django Storage Backend systems

查看:143
本文介绍了多个Django存储后端系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用S3BotoStorage后端存储在Amazon S3上载文件Django应用程序。但在网络API服务(使用Django-tastypie),它是需要长时间来上传文件的S3。 通过Web服务器,然后到Amazon S3存储后端,因为有请求通过。

I have django application that was using S3BotoStorage backend to store uploaded files on Amazon s3. But in web api services(using django-tastypie) it was taking long time to upload file on s3. As there were request passes through web server and then to amazon s3 storage backend.

那么,我们来用的解决方案,让他们先上传的Web服务器上,实现Django的芹菜任务,通过该文件被上传到Amazon S3。这是成品和工作。 但在那之后我们要修改的文件的URL到Amazon S3存储位置的URL。 但是,当我们尝试修改file_field_obj.storage到s3botostroage。这得到将其恢复为默认的文件存储如预期。

So, we come with solution to let them upload first on Web server and implement django-celery tasks through which files get uploaded to amazon s3. It is finished and working. But after that we want to modify the url of files to amazon s3 storage location urls. But when we try to modify file_field_obj.storage to s3botostroage. This gets revert it back to Default File Storage as expected.

那么,有没有我们可以在S3上的文件上传后修改的Django模型的FileField存储领域的任何选项。因此,在设置中会有DefaultFileStorage指向FileSystemStorage。 但是,如果文件是在S3上,然后,他们将指向S3存储位置。

So is there any option we can modify Django Models FileField storage field after uploading files on s3. So, in settings there will be DefaultFileStorage pointing to FileSystemStorage. But if files are on s3 then, they will point to s3 storage locations.

推荐答案

该解决方案已经存在的应用程序:的 Django的排队存储

The solution already exists in an app: django-queued-storage

这应该处理创造芹菜任务的存储后端之间的上传。

It should handle creating celery tasks that uploads between the storage backends.

这篇关于多个Django存储后端系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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