creating objects with user-provided Last-Modified

3 views
Skip to first unread message

Gavriel Fleischer

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

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 = Time.at(1437600000)

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)

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

geemus (Wesley Beary)

unread,
Aug 3, 2015, 5:06:03 PM8/3/15
to ruby...@googlegroups.com
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 ruby-fog+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages