How to save a PDF file in the database and make it available for download?

3

I'm developing a web application using PlayFramework, and I'm needing a file that will be a kind of guide (documentation) for the users that will use my application to download or view by the browser itself to guide you in the handling of the platform . I am using the local database for now, the H2 to store my data. How do I save this pdf document in my bank so I can make it available later for download or visualization?

Here is one of the classes of the bank, where you could insert the pdf file here.

@Entity
public class Auditoria extends Model{

public String usuario;
public String action;
public String controller;
@Temporal(TemporalType.TIMESTAMP)
public Date data;   

public Auditoria(){
    this.data = new Date();
}
}
    
asked by anonymous 02.01.2018 / 14:20

1 answer

-2

You can save any file in an sql database using a varbinary (max) column.

Just create a method that converts the file to binary and saves it in the DB, and then to read it, just do the reverse.

    
02.01.2018 / 14:39