1
votes

I have a web form (see dummy example below), it's printed by an agent.

When form is submitted it's processed by an agent (LS).

I do not know how to retrieve files/attachments, that is my problem.

<form name="profile" method="POST" action=".../postAgentName?openagent">
<input name="title"/>
<input name="price"/>
...
<input type="file" name="files" multiple>
</form>

Attachments are not part of DocumentContext as far as I see but only file-names. I kind of suspect files could be temporary uploaded to Domino within request somewhere but really I'm not sure?

Is it possible to get attachments using LotusScript from "files" controller within agent written in LS? Can somebody point me in right direction? or maybe give a tip what should I do?

Thanks a lot.

1

1 Answers

1
votes

I have built my own solution

  1. when we select files on client side - we convert them to base64 with javascript
<form name="formName" method="post" action="agentName?openagent">
<input name="title" value="xxx">
<input type="file" name="files" multiple onchange="toBase64()">
</form>
  1. we add base64 strings to form just like normal so they will be submitted to endpoint (agent)

var reader = new FileReader();

  1. agent will get base64 value and convert it back to file (using LS or Java/LS2J)

Call stream.WriteText(base64File)

Call item.SetContentFromText(stream, contentType, ENC_BASE64)

See details here (could not format properly here): https://dpastov.blogspot.com/2021/01/how-to-post-attachments-using-form-to.html