Hello community, here is the log from the commit of package python-django-minio-storage for openSUSE:Factory checked in at 2020-04-07 10:28:00 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-django-minio-storage (Old) and /work/SRC/openSUSE:Factory/.python-django-minio-storage.new.3248 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-django-minio-storage" Tue Apr 7 10:28:00 2020 rev:4 rq:791485 version:0.3.7 Changes: -------- --- /work/SRC/openSUSE:Factory/python-django-minio-storage/python-django-minio-storage.changes 2020-01-09 22:52:23.086763035 +0100 +++ /work/SRC/openSUSE:Factory/.python-django-minio-storage.new.3248/python-django-minio-storage.changes 2020-04-07 10:28:29.534307525 +0200 @@ -1,0 +2,6 @@ +Sun Apr 5 07:50:49 UTC 2020 - Tomáš Chvátal <tchva...@suse.com> + +- Update to 0.3.7: + * no changelog + +------------------------------------------------------------------- Old: ---- django-minio-storage-0.3.5.tar.gz New: ---- django-minio-storage-0.3.7.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-django-minio-storage.spec ++++++ --- /var/tmp/diff_new_pack.iMzb5Q/_old 2020-04-07 10:28:29.930307966 +0200 +++ /var/tmp/diff_new_pack.iMzb5Q/_new 2020-04-07 10:28:29.934307970 +0200 @@ -20,7 +20,7 @@ %bcond_with test %define skip_python2 1 Name: python-django-minio-storage -Version: 0.3.5 +Version: 0.3.7 Release: 0 Summary: Django file storage using minio License: MIT OR Apache-2.0 ++++++ django-minio-storage-0.3.5.tar.gz -> django-minio-storage-0.3.7.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-minio-storage-0.3.5/CHANGELOG.md new/django-minio-storage-0.3.7/CHANGELOG.md --- old/django-minio-storage-0.3.5/CHANGELOG.md 2019-12-16 12:40:45.000000000 +0100 +++ new/django-minio-storage-0.3.7/CHANGELOG.md 2020-02-26 09:24:31.000000000 +0100 @@ -1,4 +1,25 @@ ---- NEXT +## 0.3.7 + +Removed accidentally left over debug print from previous release + +## 0.3.6 + +### support adding default meta data + +Also new settings: MINIO_STORAGE_MEDIA_OBJECT_METADATA and +MINIO_STORAGE_STATIC_OBJECT_METADATA + +example: + +```py +MINIO_STORAGE_MEDIA_OBJECT_METADATA = {"Cache-Control": "max-age=1000"} +``` + +### fix issue with directory listing names + +Minio has changed in the last months to be more picky about path names so we +now enure that we don't create path prefixes with a // suffix. + ## 0.3.5 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-minio-storage-0.3.5/PKG-INFO new/django-minio-storage-0.3.7/PKG-INFO --- old/django-minio-storage-0.3.5/PKG-INFO 2019-12-16 12:41:53.000000000 +0100 +++ new/django-minio-storage-0.3.7/PKG-INFO 2020-02-26 09:25:46.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: django-minio-storage -Version: 0.3.5 +Version: 0.3.7 Summary: Django file storage using the minio python client Home-page: https://github.com/py-pa/django-minio-storage Author: Tom Houlé diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-minio-storage-0.3.5/django_minio_storage.egg-info/PKG-INFO new/django-minio-storage-0.3.7/django_minio_storage.egg-info/PKG-INFO --- old/django-minio-storage-0.3.5/django_minio_storage.egg-info/PKG-INFO 2019-12-16 12:41:53.000000000 +0100 +++ new/django-minio-storage-0.3.7/django_minio_storage.egg-info/PKG-INFO 2020-02-26 09:25:46.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: django-minio-storage -Version: 0.3.5 +Version: 0.3.7 Summary: Django file storage using the minio python client Home-page: https://github.com/py-pa/django-minio-storage Author: Tom Houlé diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-minio-storage-0.3.5/docs/usage.md new/django-minio-storage-0.3.7/docs/usage.md --- old/django-minio-storage-0.3.5/docs/usage.md 2019-12-16 12:38:11.000000000 +0100 +++ new/django-minio-storage-0.3.7/docs/usage.md 2020-02-22 18:03:43.000000000 +0100 @@ -37,6 +37,11 @@ right after it's been created by `MINIO_STORAGE_AUTO_CREATE_MEDIA_BUCKET`. Valid values are: `GET_ONLY`, `READ_ONLY`, `WRITE_ONLY`, `READ_WRITE` and `NONE`. (default: `GET_ONLY`) + +- `MINIO_STORAGE_MEDIA_OBJECT_METADATA`: set default additional metadata for + every object persisted during save operations. The value is a dict with + string keys and values, example: `{"Cache-Control": "max-age=1000"}`. + (default: `None`) - `MINIO_STORAGE_STATIC_BUCKET_NAME`: the bucket that will act as `STATIC` folder @@ -53,6 +58,11 @@ right after it's been created by `MINIO_STORAGE_AUTO_CREATE_STATIC_BUCKET`. Valid values are: `GET_ONLY`, `READ_ONLY`, `WRITE_ONLY`, `READ_WRITE` and `NONE`. (default: `GET_ONLY`) + +- `MINIO_STORAGE_STATIC_OBJECT_METADATA`: set default additional metadata for + every object persisted during save operations. The value is a dict with + string keys and values, example: `{"Cache-Control": "max-age=1000"}`. + (default: `None`) - `MINIO_STORAGE_MEDIA_URL`: the base URL for generating urls to objects from `MinioMediaStorage`. When not specified or set to `None` it's value will be @@ -103,6 +113,7 @@ MINIO_STORAGE_ACCESS_KEY = 'KBP6WXGPS387090EZMG8' MINIO_STORAGE_SECRET_KEY = 'DRjFXylyfMqn2zilAr33xORhaYz5r9e8r37XPz3A' MINIO_STORAGE_USE_HTTPS = False +MINIO_STORAGE_MEDIA_OBJECT_METADATA = {"Cache-Control": "max-age=1000"} MINIO_STORAGE_MEDIA_BUCKET_NAME = 'local-media' MINIO_STORAGE_MEDIA_BACKUP_BUCKET = 'Recycle Bin' MINIO_STORAGE_MEDIA_BACKUP_FORMAT = '%c/' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-minio-storage-0.3.5/minio_storage/storage.py new/django-minio-storage-0.3.7/minio_storage/storage.py --- old/django-minio-storage-0.3.5/minio_storage/storage.py 2019-12-16 12:38:11.000000000 +0100 +++ new/django-minio-storage-0.3.7/minio_storage/storage.py 2020-02-26 09:20:12.000000000 +0100 @@ -15,6 +15,7 @@ from django.utils import timezone from django.utils.deconstruct import deconstructible from minio.helpers import get_target_url + from minio_storage.errors import minio_error from minio_storage.files import ReadOnlySpooledTemporaryFile from minio_storage.policy import Policy @@ -44,6 +45,7 @@ presign_urls: bool = False, auto_create_policy: bool = False, policy_type: T.Optional[Policy] = None, + object_metadata: T.Optional[T.Dict[str, str]] = None, backup_format: T.Optional[str] = None, backup_bucket: T.Optional[str] = None, assume_bucket_exists: bool = False, @@ -67,8 +69,8 @@ self.auto_create_policy = auto_create_policy self.assume_bucket_exists = assume_bucket_exists self.policy_type = policy_type - self.presign_urls = presign_urls + self.object_metadata = object_metadata self._init_check() @@ -126,7 +128,12 @@ content.seek(0) content_size, content_type, sane_name = self._examine_file(name, content) self.client.put_object( - self.bucket_name, sane_name, content, content_size, content_type + self.bucket_name, + sane_name, + content, + content_size, + content_type, + metadata=self.object_metadata, ) return sane_name except merr.ResponseError as error: @@ -193,10 +200,11 @@ # function will just return empty results, this is different from # FileSystemStorage where an invalid directory would raise an OSError. - if path in [None, "", "."]: + if path in [None, "", ".", "/"]: path = "" else: - path += "/" + if not path.endswith("/"): + path += "/" dirs: T.List[str] = [] files: T.List[str] = [] @@ -299,7 +307,7 @@ def get_setting(name, default=_NoValue): result = getattr(settings, name, default) if result is _NoValue: - print("Attr {} : {}".format(name, getattr(settings, name, default))) + # print("Attr {} : {}".format(name, getattr(settings, name, default))) raise ImproperlyConfigured else: return result @@ -346,6 +354,9 @@ "MINIO_STORAGE_ASSUME_MEDIA_BUCKET_EXISTS", False ) + object_metadata = get_setting("MINIO_STORAGE_MEDIA_OBJECT_METADATA", None) + # print("SETTING", object_metadata) + super().__init__( client, bucket_name, @@ -357,6 +368,7 @@ backup_format=backup_format, backup_bucket=backup_bucket, assume_bucket_exists=assume_bucket_exists, + object_metadata=object_metadata, ) @@ -384,6 +396,8 @@ "MINIO_STORAGE_ASSUME_STATIC_BUCKET_EXISTS", False ) + object_metadata = get_setting("MINIO_STORAGE_STATIC_OBJECT_METADATA", None) + super().__init__( client, bucket_name, @@ -393,4 +407,5 @@ base_url=base_url, presign_urls=presign_urls, assume_bucket_exists=assume_bucket_exists, + object_metadata=object_metadata, ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/django-minio-storage-0.3.5/tests/test_app/tests/upload_tests.py new/django-minio-storage-0.3.7/tests/test_app/tests/upload_tests.py --- old/django-minio-storage-0.3.5/tests/test_app/tests/upload_tests.py 2019-10-17 08:22:36.000000000 +0200 +++ new/django-minio-storage-0.3.7/tests/test_app/tests/upload_tests.py 2020-02-22 18:00:21.000000000 +0100 @@ -1,11 +1,11 @@ import os import requests - from django.conf import settings from django.core.files.base import ContentFile, File from django.test import TestCase, override_settings from minio.error import InvalidAccessKeyId + from minio_storage.storage import MinioMediaStorage from .utils import BaseTestMixin @@ -82,3 +82,25 @@ self.assertTrue(self.media_storage.exists(".hidden_file")) self.media_storage.delete(".hidden_file") self.assertFalse(self.media_storage.exists(".hidden_file")) + + def test_metadata(self): + ivan = self.media_storage.save("pelican.txt", ContentFile(b"Ivan le Pelican")) + res = self.media_storage.client.stat_object( + self.media_storage.bucket_name, ivan + ) + self.assertEqual(res.metadata, {"Content-Type": "text/plain"}) + + +@override_settings( + MINIO_STORAGE_MEDIA_OBJECT_METADATA={"Cache-Control": "max-age=1000"}, +) +class TestDefaultObjectMetadata(BaseTestMixin, TestCase): + def test_default_metadata(self): + ivan = self.media_storage.save("pelican.txt", ContentFile(b"Ivan le Pelican")) + res = self.media_storage.client.stat_object( + self.media_storage.bucket_name, ivan + ) + self.assertEqual( + res.metadata, + {"Cache-Control": "max-age=1000", "Content-Type": "text/plain"}, + )