次のページで行うことと同じことを、PHP で行いました。
Bluemix の Cloudant から、python3 で画像ファイルをダウンロード
from_cloudant.rb
#! /usr/bin/ruby
# -*- coding: utf-8 -*-
#
# from_cloudant.rb
#
# Jul/28/2017
#
require 'restclient'
require 'json'
#
# ---------------------------------------------------------------------
#
puts "*** 開始 ***"
#
#
url="https://44b508dd-f332-4f91-81f2-78369c7d29d9-bluemix:9dacdfdee131c2a5c16596fc371012e08a61e7132d3b21ecaaf1f63a265fae64@efc189dc-f332-4f51-81f2-78391c7d29d9-bluemix.cloudant.com"
#
url_collection = url + '/jpg'
url_docs = url_collection + '/_all_docs'
puts url_docs
str_json = RestClient.get url_docs
#
list_aa=JSON.parse(str_json)
#
dict_aa={}
list_aa['rows'].each {|row|
key = row['key']
file_jpg = key + '.jpg'
puts key
url_target = url_collection + '/' + key + '/' + file_jpg
puts url_target
image = RestClient.get url_target
File.open(file_jpg,"w") do |fp_out|
fp_out.puts image
end
}
#
puts "*** 終了 ***"
#
# ---------------------------------------------------------------------