七牛callback问题

在django下调用七牛云存储服务,文件能上传成功,但是callback存在问题,返回500,请大家帮忙看看,谢谢了。
urls.py

urlpatterns = patterns('',
    # Examples:
    url(r'^$', 'ifile.views.home', name='home'),
    url(r'^callback/', 'ifile.views.upload_callback'),
)

view.py

def upload_callback(request):

    download_url = ''

    if not request.POST.has_key('key'):
        print 'request has not key attribute'

    if request.method == 'POST':
        if request.POST.has_key('key'):
            key = request.POST['key']
            download_url = qiniu.rs.make_base_url(Q_DOMAIN, key)
    else:
        print 'request not belong to POST'

    return HttpResponse(json.dumps(download_url), content_type="application/json")
{"error":"{\"callback_url\":\"http://lab.icecoffee.cn/callback\",\"callback_bodyType\":\"application/x-www-form-urlencoded\",\"callback_body\":\"key=aocpT.jpg\",\"token\":\"\",\"err_code\":500,\"error\":\"Internal Server Error\"}"}

apache2日志:
lab.icecoffee.cn:80 183.136.139.11 - - [05/Sep/2015:17:41:50 +0800] "POST /callback HTTP/1.1" 500 9132 "-" "qiniu-callback/1.0"

curl -v http://lab.icecoffee.cn/callback/ -X POST -d 'key=1012_director_video_296413.mov\u0026hash=FnSIb1-sMjU5yadzz1z2mtRbS4kD\u0026ext=.mov\u0026time=3.000000\u0026bucket=directoruploadvideos\u0026height=1080\u0026width=1920’

通过定位发现了问题,在view里面加上@csrf_exempt 解决问题

阅读 4k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
logo
七牛云问答
子站问答
访问
宣传栏