code_junkie

Uploading files in Ruby on Rails

Nov 11th, 2011
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. BOUNDARY = "AaB03x"
  2.  
  3. def encode_multipartformdata(parameters = {})
  4. ret = String.new
  5. parameters.each do |key, value|
  6. unless value.empty?
  7. ret << "rn--" << BOUNDARY << "rn"
  8. ret << "Content-Disposition: form-data; name="#{key}"rnrn"
  9. ret << value
  10. end
  11. end
  12. ret << "rn--" << BOUNDARY << "--rn"
  13. end
Add Comment
Please, Sign In to add comment