3
I am developing a web application using Playframework, and I need a file that will be a kind of guide (documentation) for users who will use my application to be able to download or view by the browser itself in order to guide you in the handling of the platform. I’m using the local database for now, the H2 to store my data. How to save this pdf document in my bank so that it can be made available for download or viewing?
Here is one of the classes of the bank, where could be inserted here the pdf file.
@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();
}
}
Have you ever considered saving the file in a directory and saving in the bank only the path of it? It is a much better alternative.
– DiegoAugusto
No, I did not know of this alternative, can help me to implement?
– Carlos Diego
I’m going home, when I get there I’ll come up with an answer for you.
– DiegoAugusto
@Diegoaugusto I stand by
– Carlos Diego
You could save as blob in Base64 in the bank but @Carlosdiego’s proposal to save the directory path from it is much better
– Rômulo Gabriel Rodrigues
Can you help me implement this @Romulogabrielrodrigues?
– Carlos Diego
Maybe only later because in my work I have no Java environment and I have no experience in this Play framework that is being used
– Rômulo Gabriel Rodrigues
Okay, I’m waiting @Romulogabrielrodrigues
– Carlos Diego
Except in very specific cases, avoid saving files in the database, try to do by references, either directory, link or file name, otherwise you may incur performance problems in the transfer among others. <br>If you even need to do binary archiving, please follow:<br> https://answall.com/questions/100802/howto function- o-campo-blob <br> https://dev.mysql.com/doc/refman/5.7/en/binary-varbinary.html
– Tamnil Saito