if not VALID_BUCKET.search(bucket) and not VALID_S3_ARN.search(bucket): TypeError: expected string or bytes-like object

330 views
Skip to first unread message

KUMBHAGIRI SIVAKRISHNA

unread,
Dec 14, 2020, 3:40:32 AM12/14/20
to django...@googlegroups.com
ile "/home/sivakrishna/Downloads/peeljobs-env/lib/python3.8/site-packages/botocore/handlers.py", line 200, in validate_bucket_name
    if not VALID_BUCKET.search(bucket) and not VALID_S3_ARN.search(bucket):
TypeError: expected string or bytes-like object


Please help me to solve this problem 

Kasper Laudrup

unread,
Dec 14, 2020, 3:43:12 AM12/14/20
to django...@googlegroups.com

Sanjay Sikdar

unread,
Jun 5, 2024, 3:40:02 AMJun 5
to Django users
django-storages has been updated that's why you are getting this error.

OLD SYNTAX
from storages.backends.s3boto3 import S3Boto3Storage
import os

class MediaStorage(S3Boto3Storage):
    bucket_name = os.environ.get('AWS_STORAGE_BUCKET_NAME')
    location = 'media'

class StaticStorage(S3Boto3Storage):
    bucket_name = os.environ.get('AWS_STORAGE_BUCKET_NAME')
    location = 'static'
UPDATED SYNTAX

STORAGES = {
        "default": {
            "BACKEND": "storages.backends.s3.S3Storage",
            "OPTIONS": {
                "bucket_name": AWS_STORAGE_BUCKET_NAME,
                "location": 'media'
            },
        },
        "staticfiles": {
            "BACKEND": "storages.backends.s3.S3Storage",
            "OPTIONS": {
                "bucket_name": AWS_STORAGE_BUCKET_NAME,
                "location": 'static'
            },
        },
    }
Reply all
Reply to author
Forward
0 new messages