I am making an application to be able to see files in a pdf viewer or imageView depending on the type of file.
I get the files using the library jtds 1.3.0 from SQL Server 2012, from a field of type varbinary(max)
that contains the binary file of a pdf or an image. A query returns the field I put in a variable of type InputStream
.
What do I have to do to open the file in a pdf viewer or in an imageview?
This is my code (in kotlin):
val pst = conexionDB2()!!.prepareStatement("SELECT * FROM tbOT_Archivos")
val rs = pst.executeQuery()
rs.next()
val nombre = rs.getString("OTf_NombreArchivo")
val rest = rs.getBinaryStream("OTf_Archivo")
The variable rest is of type InputStream
.
The variable name has the name of the file, for example: file.pdf or image.png, so I know what type of file to send to the pdf viewer or the imageview.
All part of that I have a InputStream
in a variable, what comes?