Save file on server side from database (WebClient)

Hi all.

I’m developing a Web Client solution with some pictures saved on the database as blob fields (server side). How can I store those files on the same server without creating a local side temp file and stream it again to the server?

Thanks in advance !!
Best Regards. Roberto Blasco.

You can run a client on the server and process your table.
Client can be smart- as well as headless, this depends on whether this is a 1 time job or should be done continuously.

Thanks a lot mboegem, I’l’ try it.

Best regards. Roberto Blasco.

Hello:

Roberto, you can use a stored procedure in the database, that for example, when insert or update record, save the blob field to a file system and assign null value to field, if the field isn’t neccesary in the record.

If the database is Postgresql, the procedures run with “select” for this, You can also run this procedure from servoy with getDataSetByQuery(…) In another database engine … I don’t know.

Best regards.

Good Idea !!! Adelo :D :D

Thanks a lot

Best regards. Roberto Blasco

I still wonder: what exactly do you want to do? What is the user story here?

Hi Jan.

What I want to do is to store files on server side in a file system, but, without uploading then from the client side.

The story is the following one … :D

One solution running disconnected from the server, this solution has to be able to store pictures,docs… in the database. When in my office, the local solution has to be synchronized with the one deployed in the server. One programmed schedule will store those files in the server side, will set to null the blob field and will fill the server pathname field of the file (MD5/SHA-1-) in that table.

If a work team has to go outside again with the disconnected solution and save more files in the database, those will be stored by the schedule job in an automatic way when the solution will synchronized.

Same solution … One disconnected (without the schedule job) able of storing files in the database and the other one running in a server with the files linked through the pathname to a file system.

So, that’s why I want to know how to store files in a folder in the server with a process running on server side :D

Thanks in advance, and sorry because my English …

Best regards. Roberto Blasco

Hi Roberto,

So if I understand correctly there is some offline client that may sync with the server and then the server wants to store the images that were stored in the database to the filesystem when convenient.
Yes you could use stored procedures for this but in PostgreSQL’s case you need to use pl/perlU (as in Untrusted) to be able to write to the filesystem (see http://www.postgresql.org/docs/9.3/stat … usted.html).
But I think you will still have permission problems if any other process than PostgreSQL has to access it (like Servoy Server).
So my best guess is to use a batch process in Servoy Server and write the BLOB data to files using the file plugin.

Hope this helps.

Thanks ROCLASI.

As Adelo and you say I think the best choice is the combination between Postgres Stored Procedures and a batch processor in Servoy Servet.

Thanks a lot.
Best Regards. Roberto Blasco.

Hi Roberto,

Roberto Blasco:
As Adelo and you say I think the best choice is the combination between Postgres Stored Procedures and a batch processor in Servoy Servet

I actually didn’t say it was the best choice, just that it was technically feasible.

How are the files being access after they have been written to the filesystem? Through stored procedures? That is not very efficient.
Also you say you synchronize the offline client to the database, how ? Is this Mobile Client? If so why not directly write the files to the filesystem from the headless client who handles the syncing.
If it’s a regular offline client you could use the same method as well (REST).

Hope this helps.

Mmmm.

I’ve to study this way … XD XD

Thanks a lot.