xxx
xxx

Reputation: 516

Rails save file as image

I use webdav protocol. gem 'net_dav' it's old but usefull

when i get file through it i receive it like this \xFF\xD8\xFF\xE0\x00\x10JFIF\x00\x01\x01\x01\x00H\x00H\x00\x00\xFF\...

How to convert to real image .jpg or .png?

Upvotes: 1

Views: 403

Answers (1)

Saqib
Saqib

Reputation: 685

you will have to decode this base64 string and then save file, something like

File.open('file_name.jpg', 'wb') do|f|
  f.write(Base64.decode64(base_64_encoded_string))
end

Upvotes: 3

Related Questions