All I want to do is get all the content from a local file and store it in a variable. How?
File.read(@icon.full_filename).each {|l| r += l}
only gives me a part of it. In PHP, I just used file_get_contents.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Answering my own question here… turns out it’s a Windows only quirk that happens when reading binary files (in my case a JPEG) that requires an additional flag in the open or File.open function call. I revised it to
open("/path/to/file", 'rb') {|io| a = a + io.read}and all was fine.