creating objects with user-provided Last-Modified

Skip to first unread message

Gavriel Fleischer

Aug 3, 2015, 5:05:15 PM8/3/15
to ruby-fog

I am trying to copy a file into the cloud (both to SoftLayer and to AWS) and I need to preserve the "Last-Modified" header, so when I retrieve it back from the clouds I would see the last_modified time I provided.
I can't figure out how to do it. I tried it in these ways:

dir = s3.directories.get("mybucket")
last_modified =

dir.files.create(key: "file2.txt", body: "content string", last_modified: last_modified.httpdate)

dir.files.create(key: "file2.txt", body: "content string", last_modified: last_modified)

dir.files.create(key: "file2.txt", body: "content string", 'Last-Modified' => last_modified)

dir.files.create(key: "file2.txt", body: "content string", 'Last-Modified' => last_modified.httpdate)

= "/tmp/to_upload.txt", "w+") { |file|
file.write("content string")
FileUtils.touch(path, mtime: last_modified)
dir.files.create(key: key, body: open(path))

geemus (Wesley Beary)

Aug 3, 2015, 5:06:03 PM8/3/15
I already replied to this on stackoverflow, but the short version is that, unfortunately, Last-Modified is not a value that AWS allows to be modified, it will automatically be updated when files are created or updated instead.

You received this message because you are subscribed to the Google Groups "ruby-fog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
For more options, visit

Reply all
Reply to author
0 new messages