uploading files using widget

1
0
-1

hi, i have created an file field in a bonita form using a widget and then i created a conector . what i would like is, when user select a file to upload, i would like to store the name of this file into mysql table and in the same time save it into any folder .(1)so how i can to do it.(2)how i can control all the files that will contain the folder and could decide if they can be replaced by a files that could have the same name or not.

Thanks.

1 answer

1
0
-1

A simple solution is to have a mysql table with an autoindent id column and a filename column. You store the file name in this table and retrieve the id. Then you save the file in your folder using this id (id.bin for example). This avoid duplicates.

If you want something more intelligent you could calculate a MD5 or SHA1 of the file content and use it as a key in your table and filename. If the same file is uploaded multiple times you will have only one file on the filesystem.

All of this you can do using a groovy script as a connector (or write your own connector that does those two operations)

Comments

Submitted by claz08 on Tue, 04/26/2016 - 13:28

i think that the second proposition is better than the first , so , using a Groovy script , how i can retrieve the name of files like "file.pdf" and then split it in two diferebnt parts , one of them will be "file" and the other will be ".pdf" and then replace the name "file" to "123" (that will be the id), then join this new name with the extention ".pdf" in order to save this name into a field of mysql table and in same time save it fisically this file acording with the new name that it changed.

i hope i explained.

Submitted by g.lapierre on Tue, 04/26/2016 - 13:49
Notifications