U
U
up72020-01-16 10:35:40
Java
up7, 2020-01-16 10:35:40

Is it possible to write the file received through the socket to the database?

Subject. We accept a file (server), something like this:

byte[] buffer = new byte[64*1024];
                    FileOutputStream outF = new FileOutputStream(fileName);
                    int count, total = 0;                 
                    while ((count = din.read(buffer)) != -1){               
                        total += count;
                        outF.write(buffer, 0, count);                 
                        if(total == fileSize){
                            break;
                        }
                    }

So we get it either on disk or in a stream. How to put it into the base? I've been dumb since morning (

That is, how to get access to it for inserting it into the database? And can it then be given back to the client if it is retrieved from the database?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2020-01-16
@up7

Most often, the file is saved to disk, and only the path to it is "thrown" into the database. But in some cases it makes sense to store the received data entirely in the database, use BLOBs for this .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question