Last active
August 29, 2015 14:10
-
-
Save jbilbo/fcea794c0856a6de7327 to your computer and use it in GitHub Desktop.
Little script to export photos from s3 with specific thumbnail, based on a json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'json' | |
base_url = 'project.s3.amazonaws.com' | |
# Example JSON | |
#{ | |
#"data": | |
# [ | |
# { | |
# "id": 1234, | |
# "asset_file_name": "95a4fe64c05bc47cec7f668bfe655fd0.png", | |
# "asset_content_type": "image/png", | |
# "asset_file_size": 49047, | |
# "asset_updated_at": "2014-11-10 19:43:51", | |
# "user_id": 123, | |
# "original_file_name": "ne001.png" | |
# }, | |
# ... | |
# ] | |
#} | |
file = File.read('info_photos.json') | |
data_json = JSON.parse(file) | |
data_json['data'].each do |p| | |
system "wget http://#{base_url}/asset_photos/#{p['id']}/android_tiny_mdpi/#{p['asset_file_name']}" | |
system "mv #{p['asset_file_name']} #{p['original_file_name']}.1" | |
system "wget http://#{base_url}/asset_photos/#{p['id']}/android_tiny_hdpi/#{p['asset_file_name']}" | |
system "mv #{p['asset_file_name']} #{p['original_file_name']}.2" | |
system "wget http://#{base_url}/asset_photos/#{p['id']}/android_mdpi/#{p['asset_file_name']}" | |
system "mv #{p['asset_file_name']} #{p['original_file_name']}.3" | |
system "wget http://#{base_url}/asset_photos/#{p['id']}/android_hdpi/#{p['asset_file_name']}" | |
system "mv #{p['asset_file_name']} #{p['original_file_name']}.4" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment