Hi,
Is it possible to store documents in a database as media (pdf, word) and show the content from Servoy, in a Form or as a separate app?
Thanks,
Hi,
Is it possible to store documents in a database as media (pdf, word) and show the content from Servoy, in a Form or as a separate app?
Thanks,
Hi
Documents are easily handled as Blob’s in servoy, you can store then in a Binary column in your DB and write the data out to files as needed.
As for showing them, the Jpedal library may be useful for PDF files but for word you can launch the default Word editor on the client system to view the files.
I have examples of both operations if needed.
Regards
Hi,
As McCourt already pointed out yes you can store binary (and text) files in a database. The question is why do you want to.
It’s way more efficient to read/write straight from/to the filesystem using the file plugin and as added bonus you can serve it up also via the web without having to push/pull it through the bottleneck that is JDBC.
I think the only use-case where you might consider to have files inside the database is for when you do versioning of some sort. And even then you could do it without storing the actual files inside the database.
Just store only meta-data and location reference of the file inside the database. As added bonus your database stays snappy and incremental backups are also a lot easier overall .
As for showing/exporting the files it makes little difference (technical-wise) if they are stored on the filesystem or in the database.
Hope this helps.
Hi Robert,
Would you say that the same is true on the question of storing image data within the database? I am developing both runtime and SaaS versions of my software, and can either go with storing images within the database itself, or external to the database. It’s easy enough, for the runtime version, to just have the users point to a local datastore for getting their images (that’s how we do it in the current, non-Servoy, version of the software), but in a SaaS model, would you recommend that a separate file structure be set up, outside the database, for storing the images? So, as new users come on board, we’d create a separate folder outside the database to hold their images?
Thanks for your thoughts.
Ron
Hi Ron,
If the images are small then there is not a real issue (performance wise) to store it inside the database (like Servoy solutions have). But I would still recommend to keep all files on the filesystem and separate tenant files into their own directories. It’s cleaner and manageable and, again, ready for serving via the web.
Hope this helps.
Thanks to all.
It seems to be better to have the documents in the filesystem. Zuke, can you please share a sample on how to show those documents to the end-user? Is there a way to launch the document with the standard app associated to it?
Thanks
Hi Robert,
These are mostly jpegs of artist’s works. They generally will store one image per work (although they could have more), and we’ve always recommended that they keep their image size below 100k. If that helps any.
Thanks again.
Ron
Hi Ron,
How are these images used in your solution ?
I am trying to upload files to the server using plugins.file.showFileOpenDialog. The dialog appears, I choose the file and “upload” it but the file is not in the Server…
function onUpload(event) {
plugins.file.showFileOpenDialog(1, null, false, null, uploadCallBack, ‘Select your Resume file’ );
}
/**
Hi Robert,
The artists store images of their work which can then be used on price lists, catalogs, etc (reports kinds of things), and also they can be displayed on several forms in the system. They could, for example, run a search for artwork involving landscapes, and then print the images for those items on a report or to a form. The normal artwork display form includes a window where an image is displayed and they can scroll through several if there is more than one associated with the artwork.
Ron
Hi Ron,
Essentially you can go either way. It all depends on how you want to implement the way you show the images (loading them via the web inside the client, loading them using the file plugin,etc.). Servoy itself has some built in functionality to show the images for you so storing them saves you all that coding to fetch and display them. On the other hand you can use HTML with URL’s (to the server) in the image tags to show the images inside a label/field.
It’s not that storing images can’t be done. I have a customer who has almost 180,000 (and counting) images stored inside a database (actually of each it stores a high-res, a low-res and a thumbnail) so it can be done. But is it ideal? I would say no. Especially if you need to backup and/or restore your data.
Hope this helps.
Hi Robert,
Yes, that helps quite a bit. Thanks so much for taking the time to share your thoughts.
Have a good weekend.
Ron
Hi Robert,
Actually, one more question.
Let’s say that I decide to store the images outside of the database on the server. Would there be a preferred way to structure that, do you think?
One way would be to have one master folder, called, say “images”, and then have a subfolder for each user that contains the individual image files.
Another way would be to create a separate folder for each user, that is, no master folder that holds everything.
Would one method have any advantages over the other as far as Servoy is concerned? I would think that from a management of data standpoint, having that high level hierarchy, ie, the “images” folder, might have some advantages.
Thanks again.
Ron
RonG:
Would there be a preferred way to structure that, do you think?
A directory hierarchy that makes sure image names are unique at minimum. We’ve played around with UUID’s for folder names but prefer a more readable folder structure if possible. An example:
[attachment=0]Screen shot 2013-03-22 at 1.47.30 PM.png[/attachment]
dfernandez:
I am trying to upload files to the server using plugins.file.showFileOpenDialog. The dialog appears, I choose the file and “upload” it but the file is not in the Server…
Some example code from 5.2 days that still works: https://www.servoyforge.net/projects/su … _stream.js
Would do things a bit differently now but should give you some ideas.
Hi David,
Thanks for your thoughts. I was considering using UUIDs because we use UUIDs for their tenant_ids, so there’d be a direct match. I’ll have to think on that a bit.
But, basically then, you’d have a structure like…
-images
—really long name (UUID)
--------individual file names
—another really long name (UUID)
--------individual file names
—etc
Ron
Ron -
From the sounds of your app, it may be worth checking out Sutra CMS for ideas and code. It includes a fairly extensive asset management app. Core data structures, UI, meta data key/value storage, tagging, various functionality, etc:
[attachment=2]asset-management.png[/attachment]
Scaling:
[attachment=1]scale.png[/attachment]
Visual chooser with search built in:
[attachment=0]chooser.png[/attachment]
That’s a pretty awesome looking app, there, David. I’ll be sure to give it a look over the weekend.
Thanks again.
Ron