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

Для скачивания файла есть такая схема:
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))
 

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

Сегодня
Вчера
Эта неделя
Прошлая неделя
Этот месяц
Прошлый месяц
Вся статистика
197
3
291
26686
346
219
27007

IP: 52.14.205.205
Время: 2024-09-19 02:50:05
Счетчик joomla