Django搭在heroku上的项目,上传图片之后过了几个小时之后就无端端(消失?)找不到了

157 views
Skip to first unread message

Ragnarok

unread,
Aug 14, 2012, 10:35:30 AM8/14/12
to pyth...@googlegroups.com

最近做的一个项目临时放在了heroku上,在admin site中,在上传图片之后,是能够正常上传的,图片也能够正确找到,图片的URL也正确,可是在上传之后大概2-3小时之后,再次进入图片原来的URL,就找不到图片了。。Error 404,附上setting中的配置:
HERE = os.path.dirname(os.path.abspath(__file__))
MEDIA_ROOT = os.path.join(HERE, 'media/').replace('\\', '/')
MEDIA_URL = SITE_URL + '/media/'
STATIC_ROOT = os.path.join(HERE, 'static/').replace('\\', '/')
STATIC_URL = '/static/'
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage'

而在urls.py中,我是这样写的:
urlpatterns += patterns('',
         # avatar
         (r'^media/avatar/(?P<path>.*)$', 'django.views.static.serve',
             {'document_root': os.path.join(settings.MEDIA_ROOT, 'avatar').replace('\\', '/')}),
)

求解~有没有人知道这个问题怎么解决?

vicalloy

unread,
Aug 14, 2012, 11:11:12 AM8/14/12
to pyth...@googlegroups.com
很久没碰heroku,可能记的不太清楚。
印象中是:
heroku 上的文件都是由git管理,你需要上传的文件不能放在Heroku上。放上去也会被Heroku认为是没有被git管理的文件。
文件上传的功能你应当使用亚马逊的S3之类的第三方存储服务。

2012/8/14 Ragnarok <okon...@gmail.com>

周俊杰

unread,
Aug 14, 2012, 12:07:21 PM8/14/12
to pyth...@googlegroups.com
噢,怪不得过了两三个小时之后文件就不见了,难道是因为heroku这个时间检查然后认为这个不是被git管理的文件?

--
邮件来自: `CPyUG`华蟒用户组(中文Python技术邮件列表)
规则: http://code.google.com/p/cpyug/wiki/PythonCn
发言: pyth...@googlegroups.com
退订: python-cn+...@googlegroups.com (向此发空信即退!)
详情: http://code.google.com/p/cpyug/wiki/CpyUg
严正: 理解列表! 智慧提问! http://wiki.woodpecker.org.cn/moin/AskForHelp

邓超

unread,
Aug 14, 2012, 8:48:34 PM8/14/12
to pyth...@googlegroups.com
关注一下,底下打算用heroku的说。
--
Deng Chao

William Herry

unread,
Aug 14, 2012, 9:05:14 PM8/14/12
to pyth...@googlegroups.com
用Octopress在heroku上搭的博客不FQ上不去

2012/8/15 邓超 <knif...@gmail.com>



--



William Herry

====================

WilliamH...@Gmail.com

lee Alexander

unread,
Aug 14, 2012, 9:19:46 PM8/14/12
to pyth...@googlegroups.com
heroku上得用S3存储静态文件,不过S3需要绑定信用卡

你可以试试 https://github.com/ipconfiger/pyImageServer 可以部署在新浪SAE或者百度BAE,不需要绑定信用卡的。

Felinx Lee

unread,
Aug 14, 2012, 9:28:55 PM8/14/12
to pyth...@googlegroups.com
耶,打起广告了:)

2012/8/15 lee Alexander <superp...@gmail.com>



--
What can change the nature of a man?(Planescape Torment)
----------------------------------------------------------------------------------------
http://feilong.me            Felinx Lee's Blog (Chinese Only)

lee Alexander

unread,
Aug 14, 2012, 9:38:53 PM8/14/12
to pyth...@googlegroups.com
 正好合适哇
360.gif
Reply all
Reply to author
Forward
0 new messages