Work in progress: django-imagekit but for all types of media files (movies, PDFs etc.). + private media
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

49 lines
1.6 KiB

# # -*- coding: utf-8 -*-
# from __future__ import unicode_literals
# import os
# import warnings
# from django.conf import settings
# from django.core.files.storage import FileSystemStorage
# from django.utils._os import safe_join
# ORIGINAL_FILE_PREFIX = 'original'
# CACHED_VARIANT_PREFIX = 'cache'
# MANUAL_VARIANT_PREFIX = 'manual'
# # TODO ? @deconstructible
# class ProtectedMediaAssetStorage(FileSystemStorage):
# """
# Alllows uploads to /original/-subdirectories, but never provides URLs
# to those files, instead raising an error.
# """
# ORIGINAL_FILE_PREFIX = ORIGINAL_FILE_PREFIX
# FILENAME_MAX_LENGTH = FILENAME_MAX_LENGTH
# def __init__(self, location=None, base_url=None, **kwargs):
# if location is None:
# location = getattr(settings, 'PROTECTED_MEDIA_ROOT', settings.PROTECTED_MEDIA_ROOT)
# super(ProtectedMediaAssetStorage, self).__init__(location=location, base_url=None, **kwargs)
# def delete(self, name):
# super(ProtectedMediaAssetStorage, self).delete(name)
# # FIXME Delete all cached files, too
# warnings.warn("Cached files for asset \"%s\" are not deleted." % name)
# def path(self, name):
# """
# `name` must already contain the whole asset filesystem path.
# """
# return safe_join(self.location, ORIGINAL_FILE_PREFIX, name)
# def size(self, name):
# return os.path.getsize(self.path(name))
# # def url(self, name):
# # print "storage.url"
# # # Returns the URL for fetching the original file
# # raise ValueError("This file storage is not accessible via a URL.")