2
嘗試從CRML媒體資源中提取:all(first:item)。使用遺產RETS回購。這裏是我的紅寶石示例文件:從CRML獲取圖像二進制數據
require 'rets'
client = Rets::Client.new({
login_url: 'url',
username: 'user',
password: 'password',
version: 'RETS/1.7.2'
})
begin
client.login
rescue => e
puts 'Error: ' + e.message
exit!
end
puts 'We connected! Lets get all the photos for a property...'
photos = client.find (:first), {
search_type: 'Media',
class: 'Media',
query: '(MediaModificationTimestamp=2017-04-15+),(MediaType=Image)'
}
photo = open(photo = photos['MediaURL'])
require 'base64'
image = Base64.encode64(photo.read)
File.open('property-1.gif', 'wb') do|f|
f.write(Base64.decode64(image))
end
puts photos.length.to_s + ' photos saved.'
client.logout
但我只得到一個圖像,而不是26預期。不知道這是否會成爲檢索所有列表中的所有圖像的最佳方法,在我獲得第一個圖像後。下面是關於這個問題https://github.com/estately/rets/issues/210