Skip to content

Instantly share code, notes, and snippets.

@belek
Last active March 6, 2017 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save belek/28d9474515185b13947c2cf94928793c to your computer and use it in GitHub Desktop.
Save belek/28d9474515185b13947c2cf94928793c to your computer and use it in GitHub Desktop.
django_minio post: Define custom Storage class
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
@flyudvik
Copy link

flyudvik commented Mar 6, 2017

Is it django-minio-storage https://github.com/tomhoule/django-minio-storage? Or some custom solution?

@flyudvik
Copy link

flyudvik commented Mar 6, 2017

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