0
I have a problem finding the right encoding for a file that is saved in the database through Asp.net Fileupload in sql server 2008 database with Image type. I need to migrate from a web system to an Android application using a webservice in Asp.net for communication with that sql server database, but the saved format is not matching with the files already saved. I do not understand if it is a matter of encoding (ASCII, UTF-8, ...) or problem with Encode and Decode from Base64, or if it would be more appropriate to treat the file as hexadecimal.
The file is read by the system through the fileupload component:
arquivo.ARQUIVO = FileUpload1.FileBytes
and then there’s the rescue:
contexto.SaveChanges()
the type expected by the bank is the Image
and the web system reads the file normally after saving.
I need to do the same process through a native Android application (java), so I read the file, convert to Base64 to upload to the webservice that makes the file Decode and saved in the same type in the database. When I compare the file string the string is different, so the web system understands as corrupted file, although the application normally read.
I’ve already tested command.Parameters.Add("@ARQUIVO", SqlDbType.Image).Value = bytes;
to save, but it seems to me that before this save the file format is no longer the same as the web system.
Not Base64 is byte array!
– novic
It is not a good practice to save files in the bank
– Weslley Barbosa
Thanks for the tip, but this is how I need to do it.
– Anderson Duarte de Amorim