Last active
March 6, 2017 16:03
-
-
Save belek/28d9474515185b13947c2cf94928793c to your computer and use it in GitHub Desktop.
django_minio post: Define custom Storage class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.core.files.storage import Storage | |
class MinioStorage(Storage): | |
server = 'play.minio.io:9000' | |
access_key = 'Q3AM3UQ867SPQQA43P2F' | |
secret_key = 'zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG' | |
bucket = 'mybucket' | |
secure = True | |
def __init__(self, *args, **kwargs): | |
super(MinioStorage, self).__init__(*args, **kwargs) | |
self._connection = None | |
@property | |
def connection(self): | |
if self._connection is None: | |
try: | |
self._connection = Minio( | |
self.server, self.access_key, self.secret_key, self.secure) | |
except InvalidEndpointError: | |
self._connection = None | |
return self._connection |
And I guess api key should be imported from settings.py
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is it django-minio-storage https://github.com/tomhoule/django-minio-storage? Or some custom solution?