Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should a HTTP POST'ed file be base64 encoded?

Tags:

http

base64

I'm currently implementing a client application that POST's a file over HTTP and have implemented base64 encoding on the file's data parameter.

However, it appears that when inspecting the traffic between a simple HTML page with a file upload form and the server that no Content-Transfer-Encoding header is sent in the body when describing the file's parameter.

Is this the preferred way of POST'ing a file over HTTP?

like image 420
andybee Avatar asked Mar 17 '10 16:03

andybee


People also ask

Does Base64 need to be URL encoded?

No, you would need to url-encode it, since base64 strings can contain the "+", "=" and "/" characters which could alter the meaning of your data - look like a sub-folder.

Why would you Base64 encode a file?

Base64 encoding schemes are commonly used when there is a need to encode binary data that needs to be stored and transferred over media that are designed to deal with ASCII. This is to ensure that the data remain intact without modification during transport.

Can you Base64 encode a file?

Base64 is an encoding algorithm that converts any characters, binary data, and even images or sound files into a readable string, which can be saved or transported over the network without data loss. The characters generated from Base64 encoding consist of Latin letters, digits, plus, and slash.

Is URL encoding the same as Base64?

The URL encoding is the same as Basic encoding the only difference is that it encodes or decodes the URL and Filename safe Base64 alphabet and does not add any line separation. String encodedURL = Base64.


1 Answers

No, the preferred way is using multipart/form-data encoding, exactly as you would use with HTML form based file uploads.

like image 193
BalusC Avatar answered Nov 16 '22 01:11

BalusC