3

I develop for iOS primarily and I'm flirting with Rails as I divorce PHP, so I'm having my first encounter with Paperclip.

Looking for a simple example of the request format Paperclip is expecting, it seems that everyone is encoding their images to base64 on the client before sending the data to Rails. But when their Rails receives the data, they just unpack the base64 and pass the image into paperclip.

Why do people encode and decode their image data when sending it to rails?

Is there any way that a plaintext png byte stream would get corrupted where base64 wouldn't? Or is this just an early optimization for security reasons?

user
  • 3,388
  • 7
  • 33
  • 67
  • If there's any Rails experts passing through- does the Rails html form generator automatically encode and decode uploaded files to base64? – user Jan 30 '14 at 03:13

1 Answers1

1

Here is a related question about why base64 encoding is used Why do we use Base64? and here is a quote from there that relates to embedding images in html.

Historically it has been used to encode binary data in email messages where the email server might modify line-endings. A more modern example is the use of Base64 encoding to embed image data directly in HTML source code. Here it is necessary to encode the data to avoid characters like '<' and '>' being interpreted as tags.

Community
  • 1
  • 1