Dear Orbeon team,
I am using image-attachment in hand-made Form Runner forms [code samples below]. Images are correctly being uploaded to %MY_HOME%\AppData\Local\Temp. Files in Temp obviously disappear eventually, so this is not a solution for me now. I remember seeing some instructions on how to specify where to store files in the docs, but cannot seem to find it again. Could you please point me in the right direction? Ideally, I would like to have control over a) where the files are stored (in db or file system), and b) what the file is named. It would also be useful to eventually have some image resizing functionality. Are any/all of these possible with the current implementation? Many kind thanks in advance, -Gino In the instance: <photo filename="Forest.jpg" mediatype="image/jpeg" size="664489">file:/C:/Users/username/AppData/Local/Temp/xforms_upload_948560 757945965469.tmp</photo> In the model: <xforms:bind id="plot-photo-bind" nodeset="plot/photo" type="xs:anyURI" required="false()" /> In the form: <fr:image-attachment bind="plot-photo-bind" id="plot-photo-control"> <xforms:filename ref="@filename" /> <xforms:mediatype ref="@mediatype" /> <xxforms:size ref="@size" /> </fr:image-attachment> -- You receive this message as a subscriber of the ops-users@ow2.org mailing list. To unsubscribe: mailto:ops-users-unsubscribe@ow2.org For general help: mailto:sympa@ow2.org?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws
Gino Miceli
Forest Information Systems Specialist Food and Agriculture Organization of the United Nations FAO-Finland Cooperation Programme Sustainable Forest Management in a Changing Climate Forest Management Division, Rm. D-406 Viale delle Terme di Caracalla, s.n.c. 00153 Rome, Italy http://www.fao.org/forestry |
Administrator
|
Gino,
It is your responsibility to do something at some point with the data users uploaded. The XForms engine in Orbeon Forms just stores the file for you in a temporary directory. If you use Form Runner, Form Runner will do this for you: when users save the form, it will send the attachements to the persistence layer, and for instance the eXist persistence layer will save the files in eXist. Does this make sense? Alex On Thu, Apr 8, 2010 at 4:01 AM, Miceli, Gino (FOMR) <[hidden email]> wrote: > Dear Orbeon team, > > > > I am using image-attachment in hand-made Form Runner forms [code samples > below]. Images are correctly being uploaded to > %MY_HOME%\AppData\Local\Temp. Files in Temp obviously disappear eventually, > so this is not a solution for me now. I remember seeing some instructions > on how to specify where to store files in the docs, but cannot seem to find > it again. Could you please point me in the right direction? > > > > Ideally, I would like to have control over a) where the files are stored (in > db or file system), and b) what the file is named. It would also be useful > to eventually have some image resizing functionality. Are any/all of these > possible with the current implementation? > > > > Many kind thanks in advance, > > > > -Gino > > > > In the instance: > > <photo filename="Forest.jpg" mediatype="image/jpeg" > size="664489">file:/C:/Users/username/AppData/Local/Temp/xforms_upload_948560757945965469.tmp</photo> > > > > In the model: > > <xforms:bind id="plot-photo-bind" nodeset="plot/photo" type="xs:anyURI" > required="false()" /> > > > > In the form: > > <fr:image-attachment bind="plot-photo-bind" id="plot-photo-control"> > > <xforms:filename ref="@filename" /> > > <xforms:mediatype ref="@mediatype" /> > > <xxforms:size ref="@size" /> > > </fr:image-attachment> > > > > -- > You receive this message as a subscriber of the [hidden email] mailing > list. > To unsubscribe: mailto:[hidden email] > For general help: mailto:[hidden email]?subject=help > OW2 mailing lists service home page: http://www.ow2.org/wws > > -- Orbeon Forms - Web forms, open-source, for the Enterprise - http://www.orbeon.com/ My Twitter: http://twitter.com/avernet -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Hi Alex,
Yes, in fact this makes perfect sense! However in my case I am using Form Runner and the file is still not being persisted to eXist. What requirements are there to have this work correctly? I compared a form created with Form Builder to my own custom form and cannot see any relevant differences. Also, is there an example of how to store a file uploaded in Form Runner to the local file system? Thanks for your patience! -Gino
Gino Miceli
Forest Information Systems Specialist Food and Agriculture Organization of the United Nations FAO-Finland Cooperation Programme Sustainable Forest Management in a Changing Climate Forest Management Division, Rm. D-406 Viale delle Terme di Caracalla, s.n.c. 00153 Rome, Italy http://www.fao.org/forestry |
Brief update: my element type was xs:anyUri and not xs:base64, which explains why my data wasn't getting stored to eXist. However, in my case this is the desired behavior, as the attachments can be quite large, so I prefer to persist them to the file system.
Provided that it is the application's responsibility to move the file from the temp folder to a permanent location, do you have any recommendations or preferences on how this should be done? I see a lot of discussion re this in the forums, but it seems most users ended up storing the binary data in base64 in the db. Ideally, I would like to rename and move newly uploaded files to a known location, update it's URI in the model, and possibly delete the temp file.
Gino Miceli
Forest Information Systems Specialist Food and Agriculture Organization of the United Nations FAO-Finland Cooperation Programme Sustainable Forest Management in a Changing Climate Forest Management Division, Rm. D-406 Viale delle Terme di Caracalla, s.n.c. 00153 Rome, Italy http://www.fao.org/forestry |
Administrator
|
Gino,
Form Runner also uses xs:anyURI and saves attachments as separate files in the database. Like you say, in general this is safer, especially if the attachments can be fairly large. You can see the code that does this in fr/includes/persistence-model.xml, and see the handler for the event "fr-save-action". That code first saves all the attachments and then saves the main document. Hopefully you will be able to just use that code. Alex On Fri, Apr 9, 2010 at 9:57 AM, gino-m <[hidden email]> wrote: > > Brief update: my element type was xs:anyUri and not xs:base64, which explains > why my data wasn't getting stored to eXist. However, in my case this is the > desired behavior, as the attachments can be quite large, so I prefer to > persist them to the file system. > > Provided that it is the application's responsibility to move the file from > the temp folder to a permanent location, do you have any recommendations or > preferences on how this should be done? I see a lot of discussion re this > in the forums, but it seems most users ended up storing the binary data in > base64 in the db. > > Ideally, I would like to rename and move newly uploaded files to a known > location, update it's URI in the model, and possibly delete the temp file. > > ----- > > Gino Miceli > Forestry Information Systems Specialist > > Food and Agriculture Organization of the United Nations > FAO-Finland Cooperation Programme > Sustainable Forest Management in a Changing Climate > Forest Management Division, Rm. D-406 > Forestry Department > Viale delle Terme di Caracalla, s.n.c. > 00153 Rome, Italy > Tel: +39 06 570.56765 > Fax: +39 06 570.55137 > Website: http://www.fao.org/forestry > > -- > View this message in context: http://n4.nabble.com/Storing-image-attachments-uploaded-with-fr-image-attachment-tp1773861p1819629.html > Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com. > > > -- > You receive this message as a subscriber of the [hidden email] mailing list. > To unsubscribe: mailto:[hidden email] > For general help: mailto:[hidden email]?subject=help > OW2 mailing lists service home page: http://www.ow2.org/wws > > -- Orbeon Forms - Web forms, open-source, for the Enterprise - http://www.orbeon.com/ My Twitter: http://twitter.com/avernet -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Alex, Thanks for clarifying.. I
incorrectly assumed that xs:anyURIs were meant to be stored to the file system
rather than the db. Looking more closely at
persistence-model.xml, I notice that it only persists images when
@class="fr-attachment" is defined on a bound control and on related
xforms:bind elements. (as clarified inline by the comment “Find all binds with
fb-attachment, or to which controls with fb-attachment are bound”). This
explains why my images were not being persisted. On the flipside, omitting
this attribute, I am able to bypass the default behavior of saving the db,
without modifying the original persistence-model.xml. Is this a valid
workaround? Or is there a nicer way to do this? I will then implement a
trigger in eXist to move uploaded tmp files to their resting place. Does this
make sense? -Gino
Gino Miceli
Forest Information Systems Specialist Food and Agriculture Organization of the United Nations FAO-Finland Cooperation Programme Sustainable Forest Management in a Changing Climate Forest Management Division, Rm. D-406 Viale delle Terme di Caracalla, s.n.c. 00153 Rome, Italy http://www.fao.org/forestry |
Administrator
|
Gino,
Where would you like the attachements to be stored? Would it possible to do it by modifying / creating your own implementation of a persistence layer? Alex On Sat, Apr 10, 2010 at 10:09 AM, gino-m <[hidden email]> wrote: > Alex, > > Thanks for clarifying.. I incorrectly assumed that xs:anyURIs were meant to > be stored to the file system rather than the db. > > Looking more closely at persistence-model.xml, I notice that it only > persists images when @class="fr-attachment" is defined on a bound control > and on related xforms:bind elements. (as clarified inline by the comment > “Find all binds with fb-attachment, or to which controls with fb-attachment > are bound”). This explains why my images were not being persisted. > > On the flipside, omitting this attribute, I am able to bypass the default > behavior of saving the db, without modifying the original > persistence-model.xml. Is this a valid workaround? Or is there a nicer way > to do this? > > I will then implement a trigger in eXist to move uploaded tmp files to their > resting place. Does this make sense? > > -Gino > > > > Gino Miceli Forestry Information Systems Specialist Food and Agriculture > Organization of the United Nations FAO-Finland Cooperation Programme > Sustainable Forest Management in a Changing Climate Forest Management > Division, Rm. D-406 Forestry Department Viale delle Terme di Caracalla, > s.n.c. 00153 Rome, Italy Tel: +39 06 570.56765 Fax: +39 06 570.55137 > Website: http://www.fao.org/forestry > ________________________________ > View this message in context: RE: Re: Storing image attachments uploaded > with fr:image-attachment > Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com. > > > -- > You receive this message as a subscriber of the [hidden email] mailing > list. > To unsubscribe: mailto:[hidden email] > For general help: mailto:[hidden email]?subject=help > OW2 mailing lists service home page: http://www.ow2.org/wws > > -- Orbeon Forms - Web forms, open-source, for the Enterprise - http://www.orbeon.com/ My Twitter: http://twitter.com/avernet -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Hi Alex,
I'm revisiting this problem just now and was thinking about your suggestion. Do you think it would be possible to encapsulate this functionality into a custom XBL component? The component would have to do the following: 1) Allow upload to a temporary location and preview of an image as fr:image-attachment does now 2) Allow the client (user of the component) to specify an XPath expression to form the eventual (real) file name and path 3) The component should intercept the FR persistence model's save event, executing the following steps before proceeding with save 4) Move/rename the file from the tmp location to the calculated path/name (in our case, into another directory in the webapp) 5) If unsuccessful, fail and warn. If successful update the instance w/the new filename/path and proceed with save. Do you have any ideas on how to accomplish 3, 4 and 5? Ideally I would like to extend, not replace, fr's persistence model. Thanks a million!
Gino Miceli
Forest Information Systems Specialist Food and Agriculture Organization of the United Nations FAO-Finland Cooperation Programme Sustainable Forest Management in a Changing Climate Forest Management Division, Rm. D-406 Viale delle Terme di Caracalla, s.n.c. 00153 Rome, Italy http://www.fao.org/forestry |
I am about to embark on this one alone, and would prefer to have your input before proceeding. I plan to share whatever component I create, so please let me know if you have any preference on how this is implemented or other ideas that might be useful.
Thanks!
Gino Miceli
Forest Information Systems Specialist Food and Agriculture Organization of the United Nations FAO-Finland Cooperation Programme Sustainable Forest Management in a Changing Climate Forest Management Division, Rm. D-406 Viale delle Terme di Caracalla, s.n.c. 00153 Rome, Italy http://www.fao.org/forestry |
Administrator
|
In reply to this post by gino-m
Hi Gino,
Sorry for the late answer; it is sometimes hard to keep up with the traffic here. Rather than create a special component that does this, I would rather extend/change one of the existing persistence layer. In essence, you want to have the persistence done in a mixed mode, where part of the data is stored in a database (say eXist), and part is stored on disk. Once you have this working, we can think about how to modularize this, so one can configure where form data and files go independently from each other. This is also something that we could be interested in integrating in the product, as I can imagine quite a few cases where storing files on disk can be an attractive and efficient solution. You'll let us know how it goes. Alex On Fri, May 14, 2010 at 4:13 AM, gino-m <[hidden email]> wrote: > > Hi Alex, > > I'm revisiting this problem just now and was thinking about your suggestion. > Do you think it would be possible to encapsulate this functionality into a > custom XBL component? The component would have to do the following: > > 1) Allow upload to a temporary location and preview of an image as > fr:image-attachment does now > 2) Allow the client (user of the component) to specify an XPath expression > to form the eventual (real) file name and path > 3) The component should intercept the FR persistence model's save event, > executing the following steps before proceeding with save > 4) Move/rename the file from the tmp location to the calculated path/name > (in our case, into another directory in the webapp) > 5) If unsuccessful, fail and warn. If successful update the instance w/the > new filename/path and proceed with save. > > Do you have any ideas on how to accomplish 3, 4 and 5? Ideally I would like > to extend, not replace, fr's persistence model. > > Thanks a million! > > ----- > > Gino Miceli > > Forestry Information Systems Specialist > > Food and Agriculture Organization of the United Nations > > FAO-Finland Cooperation Programme > > Sustainable Forest Management in a Changing Climate > > Forest Management Division, Rm. D-406 > > Viale delle Terme di Caracalla, s.n.c. > > 00153 Rome, Italy > > http://www.fao.org/forestry http://www.fao.org/forestry > > > -- > View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/Storing-image-attachments-uploaded-with-fr-image-attachment-tp1773861p2216424.html > Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com. > > > -- > You receive this message as a subscriber of the [hidden email] mailing list. > To unsubscribe: mailto:[hidden email] > For general help: mailto:[hidden email]?subject=help > OW2 mailing lists service home page: http://www.ow2.org/wws > > -- Orbeon Forms - Web forms, open-source, for the Enterprise - http://www.orbeon.com/ My Twitter: http://twitter.com/avernet -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Hi Alex, Good point. I’ll try to get a “local” copy of fr working (rather
than running from the jar) and see if I can make the necessary modifications. I’ll
keep you posted.
Gino From: Alessandro Vernet
[via Orbeon Forms (ops-users)]
[mailto:[hidden email]] Hi Gino,
View message @ http://orbeon-forms-ops-users.24843.n4.nabble.com/Storing-image-attachments-uploaded-with-fr-image-attachment-tp1773861p2225362.html
Gino Miceli
Forest Information Systems Specialist Food and Agriculture Organization of the United Nations FAO-Finland Cooperation Programme Sustainable Forest Management in a Changing Climate Forest Management Division, Rm. D-406 Viale delle Terme di Caracalla, s.n.c. 00153 Rome, Italy http://www.fao.org/forestry |
In reply to this post by Alessandro Vernet
Okay, so so far I've updated FR's persistence model to recognize an optional fr:image-attachment/@path attribute. When present, it is evaluated as an AVT to determine the path to which the file should be stored when saving. If absent, the file is stored to the DB as before.
Now that I have that, do you have any ideas on the safest way to move the tmp file? I could create a custom REST service or old-style Servlet to do this, but that could easily be misused to wreak havoc. Is there a safer way to do this that is preferred? Some hook perhaps that can only be called from FR's persistence model? Perhaps a custom function? Thanks! -Gino
Gino Miceli
Forest Information Systems Specialist Food and Agriculture Organization of the United Nations FAO-Finland Cooperation Programme Sustainable Forest Management in a Changing Climate Forest Management Division, Rm. D-406 Viale delle Terme di Caracalla, s.n.c. 00153 Rome, Italy http://www.fao.org/forestry |
Administrator
|
Gino,
You would need to do this from the XPL that implements the persistence layer, right? Then I would say that the best would be to use the File processor (oxf:file). Right now it doesn't support moving, so you would have to extend it to do this. You might be able to do this by calling the appropriate Ant code. Another possibility, suggested a while ago by Eric van der Vlist, would be to create an Ant processor, that allows you to call any Ant task. http://wiki.orbeon.com/forms/doc/developer-guide/processors-file-processor Alex On Wed, May 26, 2010 at 3:28 AM, gino-m <[hidden email]> wrote: > > Okay, so so far I've updated FR's persistence model to recognize an optional > fr:image-attachment/@path attribute. When present, it is evaluated as an > AVT to determine the path to which the file should be stored when saving. > If absent, the file is stored to the DB as before. > > Now that I have that, do you have any ideas on the safest way to move the > tmp file? I could create a custom REST service or old-style Servlet to do > this, but that could easily be misused to wreak havoc. Is there a safer way > to do this that is preferred? Some hook perhaps that can only be called > from FR's persistence model? Perhaps a custom function? > > Thanks! > -Gino > > > ----- > > Gino Miceli > > Forestry Information Systems Specialist > > Food and Agriculture Organization of the United Nations > > FAO-Finland Cooperation Programme > > Sustainable Forest Management in a Changing Climate > > Forest Management Division, Rm. D-406 > > Viale delle Terme di Caracalla, s.n.c. > > 00153 Rome, Italy > > http://www.fao.org/forestry http://www.fao.org/forestry > > > -- > View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/Storing-image-attachments-uploaded-with-fr-image-attachment-tp1773861p2231361.html > Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com. > > > -- > You receive this message as a subscriber of the [hidden email] mailing list. > To unsubscribe: mailto:[hidden email] > For general help: mailto:[hidden email]?subject=help > OW2 mailing lists service home page: http://www.ow2.org/wws > > -- Orbeon Forms - Web forms, open-source, for the Enterprise - http://www.orbeon.com/ My Twitter: http://twitter.com/avernet -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Hey Alex,
I thought of doing it this way as well. Is the only way to execute the XPL via http request? My concern was that this could open the system up to attack if measures are not taken to secure the service. I realize my understanding of Orbeon's architecture is still a bit lacking so please correct me if I'm wrong. Thanks! -Gino
Gino Miceli
Forest Information Systems Specialist Food and Agriculture Organization of the United Nations FAO-Finland Cooperation Programme Sustainable Forest Management in a Changing Climate Forest Management Division, Rm. D-406 Viale delle Terme di Caracalla, s.n.c. 00153 Rome, Italy http://www.fao.org/forestry |
Free forum by Nabble | Edit this page |