S3 - Only add metadata once; use binary file content

This commit is contained in:
Bert Blommers 2020-07-12 18:29:10 +01:00
commit 8b63421321
3 changed files with 15 additions and 12 deletions

View file

@ -1081,7 +1081,7 @@ class ResponseObject(_TemplateEnvironmentMixin, ActionAuthenticatorMixin):
return 403, {}, ""
elif signed_url:
# coming in from requests.get(s3.generate_presigned_url())
if self._invalid_headers(request.url, dict(headers)):
if self._invalid_headers(request.url, dict(request.headers)):
return 403, {}, S3_INVALID_PRESIGNED_PARAMETERS
if hasattr(request, "body"):

View file

@ -6,6 +6,7 @@ from boto.s3.key import Key
import re
import six
from six.moves.urllib.parse import urlparse, unquote, quote
from requests.structures import CaseInsensitiveDict
import sys
@ -62,7 +63,7 @@ def parse_region_from_url(url):
def metadata_from_headers(headers):
metadata = {}
metadata = CaseInsensitiveDict()
meta_regex = re.compile(r"^x-amz-meta-([a-zA-Z0-9\-_]+)$", flags=re.IGNORECASE)
for header, value in headers.items():
if isinstance(header, six.string_types):