Directly serve cached files through django

This commit is contained in:
Raphael Michel
2016-09-05 23:58:16 +02:00
parent af223bd69b
commit 2576d3680d
2 changed files with 10 additions and 3 deletions

View File

@@ -5,12 +5,14 @@ from django.contrib.contenttypes.fields import GenericRelation
from django.db import models
from django.db.models.signals import post_delete
from django.dispatch import receiver
from django.utils.crypto import get_random_string
from pretix.base.i18n import I18nJSONEncoder
def cachedfile_name(instance, filename: str) -> str:
return 'cachedfiles/%012d.%s' % (instance.id, filename.split('.')[-1])
secret = get_random_string(length=12)
return 'cachedfiles/%s.%s.%s' % (instance.id, secret, filename.split('.')[-1])
class CachedFile(models.Model):