Serve media files with a static service. Dotcloud

你离开我真会死。 提交于 2019-12-13 01:48:23

问题


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).

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/'

It works perfectly.

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 works find: my django app get the media from the static service.

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.


回答1:


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.

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

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



来源:https://stackoverflow.com/questions/13727085/serve-media-files-with-a-static-service-dotcloud

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!