30 lines
683 B
Ruby
30 lines
683 B
Ruby
require "rest_client"
|
|
|
|
FILES = {
|
|
cat1: -> { File.new("cat1.jpg", mode: "rb") },
|
|
}
|
|
|
|
puts "response without sha256: "
|
|
puts RestClient.post("http://localhost:7692/store", {
|
|
content_type: "image/jpeg",
|
|
data: FILES[:cat1].call,
|
|
})
|
|
|
|
puts "response with correct sha256:"
|
|
puts RestClient.post("http://localhost:7692/store", {
|
|
content_type: "image/jpeg",
|
|
sha256: "e3705544cbf2fa93e16107d1821b312a7b825fc177fa28180a9c9a9d3ae8af37",
|
|
data: FILES[:cat1].call,
|
|
})
|
|
|
|
puts "response with incorrect sha256:"
|
|
begin
|
|
puts RestClient.post("http://localhost:7692/store", {
|
|
content_type: "image/jpeg",
|
|
sha256: "123",
|
|
data: FILES[:cat1].call,
|
|
})
|
|
rescue => e
|
|
puts e.response
|
|
end
|