def project_download_media(request, project_slug, type_, version_slug):
 version = get_object_or_404(Version.objects.public(user=request.user), project__slug=project_slug, slug=version_slug)
 privacy_level = getattr(settings, 'DEFAULT_PRIVACY_LEVEL', 'public')
 if ((privacy_level == 'public') or settings.DEBUG):
  path = os.path.join(settings.MEDIA_URL, type_, project_slug, version_slug, ('%s.%s' % (project_slug, type_.replace('htmlzip', 'zip'))))
  return HttpResponseRedirect(path)
 else:
  path = version.project.get_production_media_path(type_=type_, version_slug=version_slug).replace(settings.PRODUCTION_ROOT, '/prod_artifacts')
  (content_type, encoding) = mimetypes.guess_type(path)
  content_type = (content_type or 'application/octet-stream')
  response = HttpResponse(content_type=content_type)
  if encoding:
   response['Content-Encoding'] = encoding
  response['X-Accel-Redirect'] = path
  filename = ('%s-%s.%s' % (project_slug, version_slug, path.split('.')[(-1)]))
  response['Content-Disposition'] = ('filename=%s' % filename)
  return response

def project_download_media ( request , project_slug , type_ , version_slug ) : version = get_object_or_404 ( Version . objects . public ( user = request . user ) , project__slug = project_slug , slug = version_slug ) privacy_level = getattr ( settings , 'DEFAULT_PRIVACY_LEVEL' , 'public' ) if ( ( privacy_level == 'public' ) or settings . DEBUG ) : path = os . path . join ( settings . MEDIA_URL , type_ , project_slug , version_slug , ( '%s.%s' % ( project_slug , type_ . replace ( 'htmlzip' , 'zip' ) ) ) ) return HttpResponseRedirect ( path ) else : path = version . project . get_production_media_path ( type_ = type_ , version_slug = version_slug ) . replace ( settings . PRODUCTION_ROOT , '/prod_artifacts' ) ( content_type , encoding ) = mimetypes . guess_type ( path ) content_type = ( content_type or 'application/octet-stream' ) response = HttpResponse ( content_type = content_type ) if encoding : response [ 'Content-Encoding' ] = encoding response [ 'X-Accel-Redirect' ] = path filename = ( '%s-%s.%s' % ( project_slug , version_slug , path . split ( '.' ) [ ( - 1 ) ] ) ) response [ 'Content-Disposition' ] = ( 'filename=%s' % filename ) return response
download a specific piece of media .