使用静态服务提供媒体文件.点云 [英] Serve media files with a static service. Dotcloud

查看:107
本文介绍了使用静态服务提供媒体文件.点云的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过dotcloud(http://stackoverflow.com/questions/13681183/serve-static-files-with-nginx-and-custom)上的静态服务来为dj​​ango应用程序的媒体和静态文件提供服务-service-dotcloud).

I'm trying to serve the media and static files of my django app with a static service on dotcloud (http://stackoverflow.com/questions/13681183/serve-static-files-with-nginx-and-custom-service-dotcloud).

我创建了一个静态服务,用于放置我的静态文件.在我的django设置中,我有:

I created a static service where I put my static files. In my django settings, I have:

    STATIC_ROOT = STATIC_DIR
    STATIC_URL = 'http://mystaticapp.dotcloud.com/'

它完美地工作.

关于我的媒体文件,我将文件夹媒体放入了我的静态服务中,并且具有:

Concerning my media files, I put a folder media in my static service, and I have:

    MEDIA_ROOT = 'http://mystaticapp.dotcloud.com/media/'
    MEDIA_URL = 'http://mystaticapp.dotcloud.com/media/'

MEDIA_URL可以找到:我的django应用从静态服务获取媒体.

MEDIA_URL works find: my django app get the media from the static service.

但是问题发生在MEDIA_ROOT上.该应用似乎没有将文件上传到我的静态应用中.当我为用户上传个人资料图片时,它不会像应有的那样将其上传到mystaticapp/media/profilepic.

But the problem happens with MEDIA_ROOT. It looks like the app is not uploading the files to my static app. When I upload profile picture for my users, it does not upload it to mystaticapp/media/profilepic, as it should.

关于如何解决该问题的任何想法?谢谢.

Any idea on how I could solve that problem? Thank you.

推荐答案

要记住的重要一点是,dotCloud上的静态服务和django服务是单独的服务,没有通用的文​​件系统.因此,如果您将文件上传到django服务,则静态服务将无法使用该文件.

The important thing to remember is that the static service and your django service on dotCloud are separate services, that have no common file system. So if you upload a file to your django service, it won't be available to your static service.

对于这种用例,我建议将文件上传到S3,然后从那里提供这些文件.

For this use case I would recommend uploading your files to S3, and serving those files from there.

为此,我建议使用Django存储.这是一些文档: http://django-storages.readthedocs. org/en/latest/backends/amazon-S3.html

I would recommend Django-storages for this. Here is some documentation: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html

这篇关于使用静态服务提供媒体文件.点云的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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