Fileupload file format saved in sql server database 2008 with Image type

Asked

Viewed 47 times

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!

  • It is not a good practice to save files in the bank

  • Thanks for the tip, but this is how I need to do it.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.