Skip to content

Instantly share code, notes, and snippets.

@robyurkowski
Last active December 18, 2015 12:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robyurkowski/5784487 to your computer and use it in GitHub Desktop.
Save robyurkowski/5784487 to your computer and use it in GitHub Desktop.
Uploading a selection of S3 files' metadata
options = {
'x-amz-metadata-directive' => 'REPLACE',
'Content-Type' => 'application/pdf',
'Content-Disposition' => nil
}
count = 0
files = directory.files.each do |file|
next unless file.key =~ /pdf\z/i
count += 1
file.copy(directory.key, file.key, options)
puts "Updated #{file.key}"
end
puts "Updated #{count} files."
@ashish-kumar-goel
Copy link

How did you get the directory object? Currently, I am making use of Ruby AWS SDK version 2.
I get the list of objects in my S3 bucket, using Resource -> Bucket -> Objects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment