require "base64"
file_url = "https://s3.ap-south-1.amazonaws.com/on-store-billing/uploads/insurance/servify_device_image/58/1__2_.jpeg"
encoded_string = Base64.encode64(open(file_url) { |io| io.read })
decode_img= Base64.decode64(encoded_string)
below given method write/create image with name image.png in directory
File.open(‘image.png’, ‘wb’) { |f| f.write(decode_img) }
file_url = "https://s3.ap-south-1.amazonaws.com/on-store-billing/uploads/insurance/servify_device_image/58/1__2_.jpeg"
encoded_string = Base64.encode64(open(file_url) { |io| io.read })
decode_img= Base64.decode64(encoded_string)
below given method write/create image with name image.png in directory
File.open(‘image.png’, ‘wb’) { |f| f.write(decode_img) }
No comments:
Post a Comment