Скачивание файла с сервера

Для скачивания файла есть такая схема:
def get_file_view(request,user_name,fname):
    if not request.user.is_authenticated(): return render_to_response('index.html')
    import os,mimetypes
    file_path=os.getcwd()+UPLOAD_DIR+'/'+user_name+'/'+fname
    if os.path.exists(file_path):
        with open(file_path,'rb') as fh:
            mime=mimetypes.guess_type(file_path)
            buf=fh.read()
            response=HttpResponse(buf,content_type=mime)
            response['Content-Disposition']='attachment; filename='+fname
            response['Location']='messages/'
            return response
 
    return render_to_response('error.html',{"msg":"Похоже, файл, который Вы запросили, не найден. ;("},
                                    context_instance=RequestContext(request))
 

Администрирование

Сегодня
Вчера
Эта неделя
Прошлая неделя
Этот месяц
Прошлый месяц
Вся статистика
7
3
101
26686
156
219
26817

IP: 3.138.36.47
Время: 2024-09-19 02:29:39
Счетчик joomla