1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Bluemix の Cloudant に ruby で画像ファイルをアップロード

Posted at

次のページで行うことと同じことを、ruby で行いました。
Bluemix の Cloudant に python3 で画像ファイルをアップロード

to_cloudant.rb
# ! /usr/bin/ruby
# -*- encoding: utf-8 -*-
#
#	to_cloudant.rb
#
#					Jul/28/2017
#
require 'json'
require 'restclient'
#
# ---------------------------------------------------------------------
puts "*** 開始 ***"
#
url="https://44b508dd-f312-4f91-81f2-78369c7d29d9-bluemix:9dacdfdee142c2a5c16596fc621012e08a61e7132d3b21ecaaf1f63a835fae64@efc189dc-f332-4f91-81f2-72569c7d39d9-bluemix.cloudant.com"
#
#
url_collection = url + '/jpg'
RestClient.delete url_collection
RestClient.put url_collection, '{}'
#
keys=["A0001","A0002"]
#
keys.each {|key|
	puts key
	file_jpg = key + '.jpg'
	url_target  =  url_collection + '/' + key + '/' + file_jpg
	puts url_target
	io = open(file_jpg,"rb")
	image = io.read()	
	RestClient.put url_target, image
	}
#
puts	"*** 終了 ***"
#
# --------------------------------------------------------------------------
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?