@permission_required('view_page', raise_exception=True)
def get_file(request, slug, attachment_id=None, filename=None):
    attachment = get_object_or_404(Attachment, file__endswith=filename, page__slug=slug)
    as_attachment = ((not imghdr.what(attachment.file.path) and 'embed' not in request.GET)
                      or 'as_attachment' in request.GET)
    # ref https://github.com/johnsensible/django-sendfile
    return sendfile(request, attachment.file.path,
                    attachment=as_attachment, attachment_filename=text_type(attachment))
dataset/ETHPy150Open mgaitan/waliki/waliki/attachments/views.py/get_file/original