Free and open source ticket system written in python
1"""
2Custom storage backend for secure file attachments.
3Files stored here are not publicly accessible via web server.
4"""
5from django.core.files.storage import FileSystemStorage
6from django.conf import settings
7import os
8
9
10class SecureFileStorage(FileSystemStorage):
11 """
12 Storage backend that stores files in a secure location
13 outside the public media directory.
14 """
15
16 def __init__(self, location=None, base_url=None):
17 if location is None:
18 location = settings.SECURE_MEDIA_ROOT
19 # base_url is None to prevent public URL generation
20 super().__init__(location=location, base_url=None)
21
22 def url(self, name):
23 """
24 Override url() to return None or raise an error.
25 Files should only be accessed through the secure download view.
26 """
27 return None
28