Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR: send() to support multipart for attachments #788

Open
ebruchez opened this issue Jan 29, 2013 · 14 comments
Open

FR: send() to support multipart for attachments #788

ebruchez opened this issue Jan 29, 2013 · 14 comments

Comments

@ebruchez
Copy link
Collaborator

The send action must support sending attachments alongside the main payload.

@avernet avernet changed the title FR: Support multipart for PDF and attachments FR: Support multipart for attachments Jun 27, 2016
@avernet
Copy link
Collaborator

avernet commented Jun 27, 2016

This is even more annoying for those who are not saving through our persistence API, and have to do so, just so they can then retrieve attachments, since Form Runner's send() currently isn't able to also send attachments.

+1 from community

@ebruchez
Copy link
Collaborator Author

In addition to sending via multipart, we could also send attachments with separate PUTs or POSTs, as we now support for the PDF. There is a process parameter which allows relating multiple PUTs or POSTs. Something like:

send(content = 'attachments', ...)

Optionally, but only if that makes sense, we could also take a parameter to specify which attachment(s) we would like to send:

send(content = 'attachments', attachments = 'my-file my-pictures', ...)

@avernet
Copy link
Collaborator

avernet commented Mar 13, 2017

+1 from community

@avernet avernet changed the title FR: Support multipart for attachments FR: send() to support multipart for attachments Feb 20, 2018
@ebruchez
Copy link
Collaborator Author

+1 from customer

@ebruchez
Copy link
Collaborator Author

ebruchez commented Sep 9, 2019

+1 from customer

@avernet
Copy link
Collaborator

avernet commented Jan 18, 2021

+1 from customer

@avernet
Copy link
Collaborator

avernet commented Jul 12, 2021

+1 from customer

@ebruchez
Copy link
Collaborator Author

+1 from customer

What would it take? We already have code (putWithAttachments()) that:

  1. Finds attachment references in the XML data.
  2. Updates references to these attachments
  3. Reads those attachments
  4. Writes those attachments and the updated XML data

We "just" need to do the same but instead we need to prepare a multipart body and send it. HttpClient's MultipartEntityBuilder is probably what we should use.

@ebruchez
Copy link
Collaborator Author

Right now, send uses fr-send-submission, and creates the content with:

ref="
    let $params := xxf:split(instance('fr-send-submission-params')/@content)
    return
        if ($params = ('pdf', 'pdf-url', 'tiff', 'tiff-url')) then
           xxf:instance('fr-urls-instance')/*[name() = instance('fr-send-submission-params')/@binary-content-key]
        else if ($params = 'metadata') then
           metadata:createFormMetadataDocument()
        else
           grid-migration:dataMaybeMigratedFromEdge(
               fr:app-name(),
               fr:form-name(),
               xxf:instance('fr-form-instance')/root(),
               xxf:instance('fr-form-metadata')/root(),
               instance('fr-send-submission-params')/@data-format-version,
               instance('fr-send-submission-params')/@prune-metadata = 'true'
           )"

In order to send binary content, we use the application/octet-stream serialization, and point the ref to a URL. We would need to do the following:

  • create the binary body and save it to a temporary file
  • then point to the temporary path with the submission
  • OR bypass the submission, which we should do at some point anyway

@ebruchez
Copy link
Collaborator Author

See also what XForms says.

We could do this at the XForms submission level, but there is the difficulty of identifying attachments, for which we have reliable support outside of XForms submission, in Form Runner.

So for now I suggest we do this at the Form Runner level.

@ebruchez
Copy link
Collaborator Author

Made some progress on this. I am still wondering, however, about doing this in Form Runner vs. XForms. I started doing the former. One drawback is that for plain xml we also support annotating the data and pruning it, and this is not going to happen automatically if we create the multipart request "by hand" before passing that to xf:submission.

Solutions:

  1. support these feature (at least pruning) but call the code from Form Runner
  2. do this at the XForms level, but somehow pass a "multipart handler" from Form Runner to XForms, as at that level how to identify Form Runner attachments and their metadata is not known

@ebruchez
Copy link
Collaborator Author

ebruchez commented Sep 21, 2022

  • minimal implementation
  • relevance handling, etc.
  • consider using tokens for content, for example content = "xml attachments"
    • then we can add support for more tokens this, for example pdf, etc.
  • check pdf-url: was broken? if so fix/restore
  • update filename for pdf, etc.
  • tests
  • doc

@ebruchez
Copy link
Collaborator Author

Documented

ebruchez added a commit that referenced this issue Sep 23, 2022
ebruchez added a commit that referenced this issue Sep 23, 2022
@ebruchez
Copy link
Collaborator Author

ebruchez commented Nov 9, 2022

Not sure what kind of automated test we can run for this given the deep integration with the Form Runner code. Could we run a send action upon form load and retrieve the result?

@ebruchez ebruchez moved this from To finish to Missing tests in Orbeon Forms 2022.1 Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Orbeon Forms 2022.1
  
Missing tests
Development

No branches or pull requests

2 participants