@handle_response_format
@treeio_login_required
def file_view(request, file_id, response_format='html'):
 file = get_object_or_404(File, pk=file_id)
 if (not request.user.profile.has_permission(file)):
  return user_denied(request, message="You don't have access to this File")
 if (request.GET and ('download' in request.GET)):
  'Return url to download a file'
  fullpath = getattr(settings, 'MEDIA_ROOT', './static/media/')
  data = ''
  try:
   data = open((fullpath + str(file.content))).read()
  except IOError:
   pass
  response = HttpResponse(data, content_type='application/x-download')
  response['Content-Disposition'] = ('attachment; filename="%s"' % smart_str(file.content))
  return response
 context = _get_default_context(request)
 context.update({'file': file})
 return render_to_response('documents/file_view', context, context_instance=RequestContext(request), response_format=response_format)

@ handle_response_format @ treeio_login_required def file_view ( request , file_id , response_format = 'html' ) : file = get_object_or_404 ( File , pk = file_id ) if ( not request . user . profile . has_permission ( file ) ) : return user_denied ( request , message = "You don't have access to this File" ) if ( request . GET and ( 'download' in request . GET ) ) : fullpath = getattr ( settings , 'MEDIA_ROOT' , './static/media/' ) data = '' try : data = open ( ( fullpath + str ( file . content ) ) ) . read ( ) except IOError : pass response = HttpResponse ( data , content_type = 'application/x-download' ) response [ 'Content-Disposition' ] = ( 'attachment; filename="%s"' % smart_str ( file . content ) ) return response context = _get_default_context ( request ) context . update ( { 'file' : file } ) return render_to_response ( 'documents/file_view' , context , context_instance = RequestContext ( request ) , response_format = response_format )
single file view page .