question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ability to set last-modified of s3 keys

See original GitHub issue

with the current S3 API it’s impossible to set the last-modified time of an S3 key, however this is very useful for testing.

I found a hacky way of doing this via:

key = self._moto_svc._main_app.app_instances['s3'].view_functions['ResponseObject.key_response'].callback.__self__.backend.buckets[BUCKET_NAME].keys[KEY_NAME]
key.last_modified = LAST_MODIFIED

however it would be really useful if there was a better way to access the underlying bucket to be able to set properties like this.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
czechnologycommented, Jul 11, 2022

FYI, in newer versions you have to use:

key = moto.s3.models.s3_backends["123456789012"]["global"].buckets[BUCKET_NAME].keys[KEY_NAME]
0reactions
johncalvinyoungcommented, Aug 31, 2017

@spulec any hope of getting a way to do this in standalone server mode? I’m using moto with a Rails app and test suite, and we’re depending on last-modified logic for some tests I’d love to do in moto.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting S3 objects' last modified datetimes with boto
Here's a snippet of Python/boto code that will print the last_modified attribute of all keys in a bucket: >>> import boto >>> s3...
Read more >
Is there a way to not change an S3 object's Last-Modified date ...
Last Modified is being set automatically by AWS and we can not disable it ... You should be able to see it in...
Read more >
ListObjectsV2 - Amazon Simple Storage Service
Encoding type used by Amazon S3 to encode object keys in the response. Valid Values: url ... Sets the maximum number of keys...
Read more >
AWS S3 Last Modified date - Adrian Macal - Medium
AWS S3 is not a file system, but exposes “Last Modified” date which is a bit confusing, because S3 object is not modifiable,...
Read more >
Amazon S3 FAQs
Amazon S3 is a simple key-based object store. ... client-side library if you want to maintain control of your encryption keys, are able...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found