# Feature request: store files in database

**URL:** <https://forum.servoy.com/t/feature-request-store-files-in-database/147>\
**Category:** Classic Servoy\
**Created:** [June 18, 2003, 10:17am UTC](https://forum.servoy.com/t/feature-request-store-files-in-database/147 "2003-06-18T10:17:04Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [June 18, 2003, 10:17am UTC](https://forum.servoy.com/t/feature-request-store-files-in-database/147/1 "2003-06-18T10:17:04Z")

</div>

It would be nice to store all kinds of files, like: pdf, doc, xls etc… in the database. Not only media-files.

I don’t know if this is a limitation in the database, or a limitation in Servoy, but still… it would be nice!

---

<div class="post-metadata">

**Author:** ![Jan\_Blok](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@Jan\_Blok](https://forum.servoy.com/u/Jan_Blok)\
**Post date:** [June 23, 2003, 3:20pm UTC](https://forum.servoy.com/t/feature-request-store-files-in-database/147/2 "2003-06-23T15:20:30Z")

</div>

This is possible in 1.1 RC3

The steps are the following:  
-create a media (blob) column (dataprovider)  
-fill the dataprovider with the following script:  
media\_dp = application.readFile(‘c:/temp/’)

-to save the data(file) back to disk use:  
application.writeFile(“c:/temp/xxxx.exe”,media\_dp);

If you also want to store the filename use:  
application.getLastFileName() //this returns the last filename (which is chosen by the user).

Note: A media column can hold any kind of binary data

---

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [June 23, 2003, 6:00pm UTC](https://forum.servoy.com/t/feature-request-store-files-in-database/147/3 "2003-06-23T18:00:01Z")

</div>

WONDERFULL!!! I really like this future.  
I have 2 questions:  
1.) Saving the file to the localdisc, can this be done by an (File) dialog too??  
2.) I have put a document: test.doc in the database, Now I want to start it rightaway. Can this be done?  
Something like:

> application.executeProgram(‘program’,‘c:/temp/test.doc’);

is not working.

---

<div class="post-metadata">

**Author:** ![Jan\_Blok](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@Jan\_Blok](https://forum.servoy.com/u/Jan_Blok)\
**Post date:** [June 23, 2003, 9:17pm UTC](https://forum.servoy.com/t/feature-request-store-files-in-database/147/4 "2003-06-23T21:17:27Z")

</div>

1. yes use:  
application.writeFile(“c:/temp”,media\_dp);  
or  
application.writeFile(“”,media\_dp);

2. yes, but write it to a file first (most pograms work only with a file)  
Example:  
application.writeFile(‘c:\temp\test.doc’,media\_dp);  
application.executeProgram(‘c:\Programfiles\office\word.exe’,‘c:\temp\test.doc’);

---

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [June 23, 2003, 10:05pm UTC](https://forum.servoy.com/t/feature-request-store-files-in-database/147/5 "2003-06-23T22:05:17Z")

</div>

OkM-i that works.

(BTW the slashes are “/” not "" Else it don’t work!)

It would be nice to have a future to open files/documents. Right out of Servoy, so the OS starts automaticly the associated program.

Now you have to determ on every machine where Word,Excel,Acrobat Reader etc..etc..is installed, and believe me, on every machine, this can be different.

Is it possible?

---

<div class="post-metadata">

**Author:** ![Jan\_Blok](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@Jan\_Blok](https://forum.servoy.com/u/Jan_Blok)\
**Post date:** [June 24, 2003, 8:49am UTC](https://forum.servoy.com/t/feature-request-store-files-in-database/147/6 "2003-06-24T08:49:22Z")

</div>

about the slashes you are correct, it is possible to use '' but have to escape them with '' resulting in:  
application.writeFile(‘c:\temp\test.doc’,media\_dp);

about starting localmachine programs, there are the following options:  
-default: application.executeProgram(‘c:\Programfiles\office\word.exe’,‘c:\temp\test.doc’);  
-place all wanted programs in path system variable (on all clients), resulting in application.executeProgram(‘word.exe’,‘c:\temp\test.doc’);  
-application.showURL(‘file:///C:/temp/test.doc’)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex010/uploads/servoy/original/1X/363c5924e316baabbea11f046f1e2f3db64fbf70.jpeg) [@system](https://forum.servoy.com/u/system)\
**Post date:** [June 24, 2003, 10:45am UTC](https://forum.servoy.com/t/feature-request-store-files-in-database/147/7 "2003-06-24T10:45:53Z")

</div>

GREAT Thanks!

---

<div class="post-metadata">

**Author:** ![Riccardino](https://avatars.discourse-cdn.com/v4/letter/r/41988e/32.png) [@Riccardino](https://forum.servoy.com/u/Riccardino)\
**Post date:** [August 25, 2003, 4:11pm UTC](https://forum.servoy.com/t/feature-request-store-files-in-database/147/8 "2003-08-25T16:11:38Z")

</div>

> Jan Blok:  
> about starting localmachine programs, there are the following options:  
> -default: application.executeProgram(‘c:\Programfiles\office\word.exe’,‘c:\temp\test.doc’);  
> -place all wanted programs in path system variable (on all clients), resulting in application.executeProgram(‘word.exe’,‘c:\temp\test.doc’);  
> -application.showURL(‘file:///C:/temp/test.doc’)

I’ve problems in writing the path to the file (or application) under OSX.  
I’m not sure to completely understand how java manages file paths: I have two discs, one of them with two partitions. So I expected to see three volumes in the open/save dialog box: but I only see the boot volume. Furthermore: this volume hasn’t the real volume name, but the computer’s name (the one you set up in system prefs, under Sharing panel).  
I tried all the permutations, but I could manage to open a file with the application I want (only application.showURL works).

Who can give me more infos?

Thanks

---

<div class="post-metadata">

**Author:** ![Neale](https://avatars.discourse-cdn.com/v4/letter/n/7ab992/32.png) [@Neale](https://forum.servoy.com/u/Neale)\
**Post date:** [August 27, 2003, 2:14am UTC](https://forum.servoy.com/t/feature-request-store-files-in-database/147/9 "2003-08-27T02:14:35Z")

</div>

Have I missed something here, or is hard-coding applications and paths thereto inviting nasty non-portabilities in to harrass us? ![:-(]( "Sad")

Surely a more portable approach would be to store a mime-type and provide a standard way for servoy to display/open/print/whatever the file, given the mime-type?

Regards,  
Neale.

---

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [August 27, 2003, 6:06am UTC](https://forum.servoy.com/t/feature-request-store-files-in-database/147/10 "2003-08-27T06:06:01Z")

</div>

Hi Neale,

that would be very nice if Servoy had that function!

---

<div class="post-metadata">

**Author:** ![Jan\_Blok](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@Jan\_Blok](https://forum.servoy.com/u/Jan_Blok)\
**Post date:** [August 27, 2003, 7:58am UTC](https://forum.servoy.com/t/feature-request-store-files-in-database/147/11 "2003-08-27T07:58:58Z")

</div>

> Riccardino:  
> I’ve problems in writing the path to the file (or application) under OSX.  
> I’m not sure to completely understand how java manages file paths: I have two discs, one of them with two partitions. So I expected to see three volumes in the open/save dialog box: but I only see the boot volume. Furthermore: this volume hasn’t the real volume name, but the computer’s name (the one you set up in system prefs, under Sharing panel).

The behaviour of the open/save dialog box is platform dependend and is managed by the Java VM (we cannot alter that behaviour)  
Did you use the application.showFileSaveDialog(…) or application.showFileOpenDialog(…) ?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex010/uploads/servoy/original/1X/363c5924e316baabbea11f046f1e2f3db64fbf70.jpeg) [@system](https://forum.servoy.com/u/system)\
**Post date:** [August 27, 2003, 8:12am UTC](https://forum.servoy.com/t/feature-request-store-files-in-database/147/12 "2003-08-27T08:12:14Z")

</div>

And the suggestions of Neale? Is that possible?

---

<div class="post-metadata">

**Author:** ![Jan\_Blok](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@Jan\_Blok](https://forum.servoy.com/u/Jan_Blok)\
**Post date:** [August 27, 2003, 8:15am UTC](https://forum.servoy.com/t/feature-request-store-files-in-database/147/13 "2003-08-27T08:15:16Z")

</div>

> Neale:  
> Have I missed something here, or is hard-coding applications and paths thereto inviting nasty non-portabilities in to harrass us?

There are several different problems  
-the file is stored in binary column, so no information about the file (mime-type) only bytes  
-the Servoy client can be running on any platform (you just don’t know)  
-As far as I know there is no way of generic opening files in applications based on mime type for each platform out there.

The only thing we could do is provide tags for temporary directory and userhome directory which you could use in your filename or url, something like ‘%%home.dir%%’ and ‘%%temp.dir%%’  
So writing/opening html file in browser would look like:  
application.writeFile(‘%%temp.dir%%/my\_file.html’,data);  
application.showURL(‘%%temp.dir%%/my\_file.html’)

Any other suggestion how to open files in applications are is welcome. ![;-)]( "Wink")

---

<div class="post-metadata">

**Author:** ![Neale](https://avatars.discourse-cdn.com/v4/letter/n/7ab992/32.png) [@Neale](https://forum.servoy.com/u/Neale)\
**Post date:** [August 27, 2003, 10:43am UTC](https://forum.servoy.com/t/feature-request-store-files-in-database/147/14 "2003-08-27T10:43:19Z")

</div>

> Jan Blok:  
> There are several different problems  
> -the file is stored in binary column, so no information about the file (mime-type) only bytes

Indeed. The mime-type would have to be separately stored or otherwise known outside the BLOB.

> Jan Blok:  
> -the Servoy client can be running on any platform (you just don’t know)

AFAICT, that’s the big redeeming feature of java ![;-)]( "Wink")

> Jan Blok:  
> -As far as I know there is no way of generic opening files in applications based on mime type for each platform out there.

Perhaps that’s the case in J2SE/J2RE, I really don’t know.

But it appears that J2EE accomodates this.  
See: [http://java.sun.com/j2ee/1.4/docs/api/j … ndMap.html](http://java.sun.com/j2ee/1.4/docs/api/javax/activation/MailcapCommandMap.html)

If it really is only in J2EE, does that make things impractically complicated?

Regards,  
Neale.

---

<div class="post-metadata">

**Author:** ![Riccardino](https://avatars.discourse-cdn.com/v4/letter/r/41988e/32.png) [@Riccardino](https://forum.servoy.com/u/Riccardino)\
**Post date:** [August 27, 2003, 12:16pm UTC](https://forum.servoy.com/t/feature-request-store-files-in-database/147/15 "2003-08-27T12:16:33Z")

</div>

> Jan Blok:  
> The behaviour of the open/save dialog box is platform dependend and is managed by the Java VM (we cannot alter that behaviour)  
> Did you use the application.showFileSaveDialog(…) or application.showFileOpenDialog(…) ?

I was using application.executeProgram: my purpose is to open a certain file with a certain application (that may be different to its default app). If I specify the path to the application (the “supposed” path I should say, since I don’t understand how path are managed by java), Servoy always gives me an error.  
I tried, for instance, to open an Acrobat pdf file using OSX Preview: I wrote the path in almost 50 different ways (using also italian file names, for Preview and the Applications folder), but it doesn’t work.  
Same thing with Applicaton.writefile and Application.readfile (so I think it’s a path related problem).

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [August 27, 2003, 2:02pm UTC](https://forum.servoy.com/t/feature-request-store-files-in-database/147/16 "2003-08-27T14:02:57Z")

</div>

I have one more thing to add to the file discussion: is it possible to get the filename? It is nice to store files in the database, but it is not so helpful if you have no clue which file it is.

---

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [August 27, 2003, 2:05pm UTC](https://forum.servoy.com/t/feature-request-store-files-in-database/147/17 "2003-08-27T14:05:39Z")

</div>

yep:

> If you also want to store the filename use:  
> application.getLastFileName() //this returns the last filename (which is chosen by the user).

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [August 27, 2003, 2:19pm UTC](https://forum.servoy.com/t/feature-request-store-files-in-database/147/18 "2003-08-27T14:19:20Z")

</div>

> If you also want to store the filename use:  
> application.getLastFileName() //this returns the last filename (which is chosen by the user).

hmm. not in my version. i don’t even see the method and it throws me an error.

---

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [August 27, 2003, 2:30pm UTC](https://forum.servoy.com/t/feature-request-store-files-in-database/147/19 "2003-08-27T14:30:34Z")

</div>

HM-i, you are right, the function is gone! I am sure it was there before because I have used it before, and expiremented with it!

Maybe Jan, can help us out!

---

<div class="post-metadata">

**Author:** ![Jan\_Blok](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@Jan\_Blok](https://forum.servoy.com/u/Jan_Blok)\
**Post date:** [August 27, 2003, 2:30pm UTC](https://forum.servoy.com/t/feature-request-store-files-in-database/147/20 "2003-08-27T14:30:56Z")

</div>

application.getLastFileName() is replaced in 1.1rc4 with  
var filename = application.showFileOpenDialog(…)

[Next page](https://forum.servoy.com/t/feature-request-store-files-in-database/147.md?page=2)
