def thumbnail(request, thumbnail): # The thumbnail id is a hash formed from file contents, so it is # essentially 1-to-1 with the thumbnail, which allows us to use # long caching times. fn = get_thumbnail_filename(thumbnail) if not os.path.isfile(fn): raise Http404 return sendfile(request, fn, mimetype="image/jpeg")
def ticket_stream(request, secret): secret = re.sub(r'\..*', '', secret) try: ticket = StreamingTicket.objects.get(secret=secret) except StreamingTicket.DoesNotExist: raise Http404 if not ticket.is_valid(request.META['REMOTE_ADDR']): return HttpResponseForbidden() video_file = ticket.video_file filename = ticket.create_symlink() response = sendfile(request, filename, mimetype=video_file.mimetype, accept_ranges=True) response['Content-Disposition'] = 'inline; filename=\"%s\"' % ticket.dummy_name return response