Closed MrArabboy closed 2 weeks ago
With latest release of minio-py
(version 7.2.8) and according to AWS S3 specification object_name
has to be a string.
Is there any consideration to encode name any more?
Simply passing object_name
as string will fix the issue.
try:
u: str = client.presigned_get_object(
bucket_name=self.bucket,
object_name=name.encode('utf-8'),
expires=get_setting("MINIO_URL_EXPIRY_HOURS", timedelta(days=7)) # Default is 7 days
)
return u
except urllib3.exceptions.MaxRetryError:
raise ConnectionError("Couldn't connect to Minio. Check django_minio_backend parameters in Django-Settings")
With latest release of
minio-py
(version 7.2.8) and according to AWS S3 specificationobject_name
has to be a string.Is there any consideration to encode name any more?
Simply passing
object_name
as string will fix the issue.try: u: str = client.presigned_get_object( bucket_name=self.bucket, object_name=name.encode('utf-8'), expires=get_setting("MINIO_URL_EXPIRY_HOURS", timedelta(days=7)) # Default is 7 days ) return u except urllib3.exceptions.MaxRetryError: raise ConnectionError("Couldn't connect to Minio. Check django_minio_backend parameters in Django-Settings")
I have model:
class PersonDocument(CreatedUpdatedAbstractModel):
person = models.ForeignKey(
"employment.Person", on_delete=models.CASCADE, related_name="documents"
)
file = models.FileField(
storage=MinioBackend(
bucket_name=settings.DOCUMENT_PRIVATE_BUCKET,
),
upload_to=get_person_document_upload_path,
)
def get_person_document_upload_path(instance: Model, filename: str) -> str:
return os.path.join(
"person", str(instance.person.id), "documents", str(filename)
).replace("\\", "/")`
error cause might be get_person_document_upload_path ?
A workaround is suggested in #51.
However, I agree with @BinDruid that removing the encoding of object_name
is the right approach since validation is handled further downstream by the minio-py
package.
I've created a PR: https://github.com/theriverman/django-minio-backend/pull/53
version 3.7.2 fixes this issue. please check, and let me know if you experience any other problems!
I updated minio package from 7.2.6 to 7.2.8 , After file uploaded to FileField and go to obj change page in django admin , raise error a bytes-like object is required, not 'str'