I'm searching for a way to download an URL with an image as binary so I can BASE64 Encode it and send it to my SAP Database. All this using RAILS.
Asked
Active
Viewed 970 times
0
-
Have you seen this http://stackoverflow.com/questions/2263540/how-do-i-download-a-binary-file-over-http – Sachin R May 24 '13 at 06:59
-
Well that's all about writing files, can't you just read an online URL instead of working with HTTP – FastSolutions May 24 '13 at 07:22
-
I think this could work: open(params[:linkedin_pic], 'rb') – FastSolutions May 24 '13 at 07:26
-
Will the above really download the file or just the headers? – FastSolutions May 24 '13 at 07:31
1 Answers
0
After I tried different things, I think the Curb gem is the best solution. This gem is found here: Ruby Gems Curb
It was easy to use like this:
curl_profile_pic = Curl::Easy.perform("example.url.jpeg)
params["personal_info"]["profile_pic"] = Base64.encode64(curl_profile_pic.body_str)

FastSolutions
- 1,809
- 1
- 25
- 49