lift user_settable_fields from (old) boto (#3468)

(old) `boto` is no longer being developed, and importing it raises
deprecation warnings. copy Key.base_user_settable_fields in here instead
of importing boto
This commit is contained in:
David Szotten 2020-11-19 09:01:53 +00:00 committed by GitHub
parent f7467164e4
commit c902de8a09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,7 +2,6 @@ from __future__ import unicode_literals
import logging import logging
import os import os
from boto.s3.key import Key
import re import re
import six import six
from six.moves.urllib.parse import urlparse, unquote, quote from six.moves.urllib.parse import urlparse, unquote, quote
@ -14,6 +13,16 @@ log = logging.getLogger(__name__)
bucket_name_regex = re.compile("(.+).s3(.*).amazonaws.com") bucket_name_regex = re.compile("(.+).s3(.*).amazonaws.com")
user_settable_fields = {
"content-md5",
"content-language",
"content-type",
"content-encoding",
"cache-control",
"expires",
"content-disposition",
"x-robots-tag",
}
def bucket_name_from_url(url): def bucket_name_from_url(url):
@ -72,7 +81,7 @@ def metadata_from_headers(headers):
if result: if result:
# Check for extra metadata # Check for extra metadata
meta_key = result.group(0).lower() meta_key = result.group(0).lower()
elif header.lower() in Key.base_user_settable_fields: elif header.lower() in user_settable_fields:
# Check for special metadata that doesn't start with x-amz-meta # Check for special metadata that doesn't start with x-amz-meta
meta_key = header meta_key = header
if meta_key: if meta_key: