Method: Aspose::Cloud::Barcode::Reader#read_from_url

Defined in:
lib/Barcode/reader.rb

#read_from_url(url, symbology) ⇒ Object

Read Barcode from External Image URL

@param string url URL of the image.
@param string symbology Type of barcode.


66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/Barcode/reader.rb', line 66

def read_from_url(url, symbology)
  raise 'URL not provided.' if url.empty?
  raise 'Symbology not provided.' if symbology.empty?

  str_uri = "#{Aspose::Cloud::Common::Product.product_uri}/barcode/recognize"
  str_uri = "#{str_uri}?type=#{symbology}&url=#{url}"

  signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
  response = RestClient.post(signed_uri, '', {:accept => 'application/json'})
  json = JSON.parse(response)
  json['Code'] == 200 ? json['Barcodes'] : nil
end