Пример #1
0
 def minio_client(self):
     minio_client = Minio(
         endpoint=get_setting("MINIO_STORAGE_ENDPOINT"),
         access_key=get_setting("MINIO_STORAGE_ACCESS_KEY"),
         secret_key=get_setting("MINIO_STORAGE_SECRET_KEY"),
         secure=get_setting("MINIO_STORAGE_USE_HTTPS"))
     return minio_client
Пример #2
0
 def minio_client(self):
     minio_client = Minio(
         endpoint=get_setting("MINIO_STORAGE_ENDPOINT"),
         access_key=get_setting("MINIO_STORAGE_ACCESS_KEY"),
         secret_key=get_setting("MINIO_STORAGE_SECRET_KEY"),
         secure=get_setting("MINIO_STORAGE_USE_HTTPS"))
     return minio_client
Пример #3
0
    def tearDown(self):
        client = Minio(endpoint=get_setting("MINIO_STORAGE_ENDPOINT"),
                       access_key=get_setting("MINIO_STORAGE_ACCESS_KEY"),
                       secret_key=get_setting("MINIO_STORAGE_SECRET_KEY"),
                       secure=get_setting("MINIO_STORAGE_USE_HTTPS"))

        def obliterate_bucket(name):
            for obj in client.list_objects(name, ""):
                client.remove_object(name, obj.object_name)
            for obj in client.list_incomplete_uploads(name, ""):  # pragma: no cover
                client.remove_incomplete_upload(name, obj.objectname)
            client.remove_bucket(name)

        obliterate_bucket("tests-media")
        obliterate_bucket("tests-static")
    def __init__(self, bucket_name=None):

        # we can create the minio client ourselves or use
        # create_minio_client_from_settings convinience function while providing it with
        # extra args.
        #
        client = create_minio_client_from_settings(
            minio_kwargs={"region": "us-east-1"})

        # or use our own Django setting
        #
        if bucket_name is None:
            bucket_name = get_setting("SECRET_BUCKET_NAME")

        # Run the super constructor and make a choice to only use presigned urls with
        # this bucket so that we can keep files more private here than how media files
        # usually are public readable.
        #
        super(SecretStorage, self).__init__(
            client,
            bucket_name,
            auto_create_bucket=True,
            auto_create_policy=False,
            presign_urls=True,
        )
Пример #5
0
    def tearDown(self):
        client = Minio(endpoint=get_setting("MINIO_STORAGE_ENDPOINT"),
                       access_key=get_setting("MINIO_STORAGE_ACCESS_KEY"),
                       secret_key=get_setting("MINIO_STORAGE_SECRET_KEY"),
                       secure=get_setting("MINIO_STORAGE_USE_HTTPS"))

        def obliterate_bucket(name):
            for obj in client.list_objects(name, ""):
                client.remove_object(name, obj.object_name)
            for obj in client.list_incomplete_uploads(name,
                                                      ""):  # pragma: no cover
                client.remove_incomplete_upload(name, obj.objectname)
            client.remove_bucket(name)

        obliterate_bucket("tests-media")
        obliterate_bucket("tests-static")
Пример #6
0
    def __init__(self):
        client = create_minio_client_from_settings()
        bucket_name = get_setting("MINIO_STORAGE_COG_BUCKET_NAME")
        base_url = get_setting("MINIO_STORAGE_COG_URL", None)
        auto_create_bucket = get_setting(
            "MINIO_STORAGE_AUTO_CREATE_COG_BUCKET", False)
        auto_create_policy = get_setting(
            "MINIO_STORAGE_AUTO_CREATE_COG_POLICY", False)
        presign_urls = get_setting('MINIO_STORAGE_COG_USE_PRESIGNED', False)
        backup_format = get_setting("MINIO_STORAGE_COG_BACKUP_FORMAT", False)
        backup_bucket = get_setting("MINIO_STORAGE_COG_BACKUP_BUCKET", False)

        super(MinioCogStorage,
              self).__init__(client,
                             bucket_name,
                             auto_create_bucket=auto_create_bucket,
                             auto_create_policy=auto_create_policy,
                             base_url=base_url,
                             presign_urls=presign_urls,
                             backup_format=backup_format,
                             backup_bucket=backup_bucket)
Пример #7
0
 def test_get_setting_throws_early(self):
     with self.assertRaises(ImproperlyConfigured):
         get_setting("INEXISTENT_SETTING")
Пример #8
0
 def test_get_setting_throws_early(self):
     with self.assertRaises(ImproperlyConfigured):
         get_setting("INEXISTENT_SETTING")