Persistence API save attachment - filename/mimetype access

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Persistence API save attachment - filename/mimetype access

mabu
Hi,

if I submit a form including an attachment, then first the persistence api to save the attachment is called and afterwards the api to save the form data.
Now, my problem is that I want to save the attachment with the original filename and mimetype. How can I achive this? The filename and mimetype are not passed as parameters to the persistence api save attachment. But they are stored in the form data xml. Do I have to parse the XML in an additional step? Or do I miss something?

I think it would be nice if the original filename and mimetype are additionally forwarded to the persistence API save attachment.

-
Martin
Reply | Threaded
Open this post in threaded view
|

Re: Persistence API save attachment - filename/mimetype access

bruno.buzzi
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Persistence API save attachment - filename/mimetype access

mabu
Hi Bruno,

Thank's for the hint. I took a look at the discussion, but I am not sure if I got the point.

1. save attachments temporary with filename {attchmentId}.bin
2. save the formdata XML
3. Select all the temporary saved attachments. For each attachment: parse the original filename from the formdata XML and save it to final path.

Is it correct?

-
Martin
Reply | Threaded
Open this post in threaded view
|

Re: Persistence API save attachment - filename/mimetype access

bruno.buzzi
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Persistence API save attachment - filename/mimetype access

Alessandro  Vernet
Administrator
In reply to this post by mabu
Hi Martin,

Would it help if the file name, size, and content type were passed to your implementation of the persistence API by Form Runner when the data was saved?

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Persistence API save attachment - filename/mimetype access

mabu
Hi Alex,

The attachment attributes file name, size and content tpye were already included in the XML when saving the form data. What do you mean exactly?
Why not passing it to the save attachment API?

Martin
Reply | Threaded
Open this post in threaded view
|

Re: Persistence API save attachment - filename/mimetype access

Alessandro  Vernet
Administrator
Hi Martin,

"Why not passing it to the save attachment API?" It's just not done, because we didn't have a need for it. But it wouldn't be hard to do. We could add those as request parameters to the query.

The code that computes the query is in saveAttachments() in FormRunnerPersistence.scala. There `holder` points to the instance node that contains the file, and that has the following attributes: filename="" mediatype="" size="". So this information could be passed on the query string. Does that feel like something you'd like to implement? If you get to implement and test it, we'll gladly look into your pull request.

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Persistence API save attachment - filename/mimetype access

mabu
Hi Alex,

Thank's for the information. Due to the fact that I am not familiar with Scala, it will take me some time to implement it. If I have some time in near future, I will give it a try because I think it would be a nice feature.
For now, I implemented it the way Bruno did.

Martin
Reply | Threaded
Open this post in threaded view
|

Re: Persistence API save attachment - filename/mimetype access

Alessandro  Vernet
Administrator
Martin, understood!

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet