def get(self, request, app_label, model_name, object_id, field_name, filename): model = get_model(app_label, model_name) if model: instance = get_object_or_404(model, pk=unquote(object_id)) if hasattr(instance, field_name): field = getattr(instance, field_name) if field.condition(request, instance): if field and os.path.exists(field.path): signals.pre_private_download.send( sender=model, instance=instance, field_name=field_name, request=request) return sendfile( request, field.path, attachment=field.attachment, attachment_filename=field.attachment_filename( request, instance, field), strong_caching=field.strong_caching) else: field.generate() return HttpResponseNotFound() else: return HttpResponseForbidden() else: return HttpResponseNotFound() else: return HttpResponseNotFound()
def get(self, request, path): try: path = find_static_file(path) return sendfile( request, path, attachment=False, strong_caching=True) except: return HttpResponseNotFound()
def get(self, request, token, filename): try: path, attachment_filename, mimetype = find_temporary_file(token) return sendfile( request, path, attachment=True, attachment_filename=attachment_filename, mimetype=mimetype) except: return HttpResponseNotFound()