lericson / simples3

Simple, quick Amazon AWS S3 interface in Python
BSD 2-Clause "Simplified" License
96 stars 36 forks source link

Make it optional to add -x-amz to metadata during copy #13

Closed madr closed 12 years ago

madr commented 12 years ago

I am trying to set some far future expiration on my files in a bucket on S3, using this python code:

future = 60*60*24*666
future_date = datetime.now() + timedelta(seconds=future)
future_date = future_date.strftime("%a, %d %b %Y %H:%M:%S GMT")

# and further down in file:
f = open(src)
s3.put(key, f.read())

s3.copy("%s/%s" % (bucket, key), key, metadata={
    "Cache-control": "max-age=%d" % future,
    "Expires": future_date})

However, when I investigate the files in firebug they do not have neither Expires och Cache-control. Instead there are prefixed versions of the metadata.

x-amz-meta-cache-control    max-age=57542400
x-amz-meta-expires  Thu, 15 May 2014 01:03:25 GMT

I would highly appreciate to set metadata and skip the "-x-amz-" prefixes.

lericson commented 12 years ago

This is not what the metadata argument is for, try headers. Closes #13

Sent from phone

Anders Ytterström reply@reply.github.com wrote:

I am trying to set some far future expiration on my files in a bucket on S3, using this python code:

future = 60_60_24*666 future_date = datetime.now() + timedelta(seconds=future) future_date = future_date.strftime("%a, %d %b %Y %H:%M:%S GMT")

and further down in file:

f = open(src) s3.put(key, f.read())

s3.copy("%s/%s" % (bucket, key), key, metadata={ "Cache-control": "max-age=%d" % future, "Expires": future_date})

However, when I investigate the files in firebug they do not have neither Expires och Cache-control. Instead there are prefixed versions of the metadata.

x-amz-meta-cache-control max-age=57542400 x-amz-meta-expires Thu, 15 May 2014 01:03:25 GMT

I would highly appreciate to set metadata and skip the "-x-amz-" prefixes.


Reply to this email directly or view it on GitHub: https://github.com/lericson/simples3/issues/13

madr commented 12 years ago

Ah, my bad. I missed headers when reading the docs. Thank you for the quick reply!