Created
September 8, 2013 16:44
-
-
Save finnp/6486332 to your computer and use it in GitHub Desktop.
Bulk uploading pictures to an app in Podio
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
require 'rubygems' | |
require 'podio' | |
app_id = '<ID of the App' | |
dir = "<Directory of images>" | |
titels = "<Image Title>" # Index gets added automatically | |
i = 1 # Starting index for the title | |
Dir.foreach(dir) do |item| | |
next if item == '.' or item == '..' or item[-3..-1] != "jpg" | |
File.open(dir + item) do |f| | |
file = Podio::FileAttachment.upload(f, item) | |
puts file.file_id | |
Podio::Item.create( app_id, { | |
:fields => { | |
"<title>" => titels + i.to_s, | |
"<image>" => file.file_id, | |
"<additional-field>" => "<e.g. general description for all the pictures" # Further fields can be added | |
} | |
} ) | |
end | |
i += 1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment