I am providing API in Ruby On Rails for android application. All going well but i am facing problem when i got base64. I didn't able to identify base64 type(image,pdf,song or any other type like doc). Is there any way to identify the exact type of base64. Thnaks in Advance.
Asked
Active
Viewed 545 times
2
-
try googling for the same, someone wrote for ruby here: http://stackoverflow.com/a/13520156/2545197 – Abhinay Aug 27 '16 at 05:01
-
but @Abhinay I want to know the type of base64 like the base64 is an image or pdf file or any other type of file...... – Jass Aug 27 '16 at 05:46
-
It very complex to identify the type of the file from base64, atleast I couldn't find it on the internet. though you can try a small hack and send `filename ` with extension as a `json` attribute along with your `base64 string` and then you dont have to run through all the code just to identify the type. – Abhinay Aug 27 '16 at 06:12
-
1I have a similar situation, and I'm afraid you'll have to submit the mime type together with the Base64 payload. We do that in our uploader code, where we extract the mime type before encoding and sending them together to the backend. – Michael Kohl Aug 27 '16 at 06:38