Now when i activate the workflow and submit a file in the form i can see the api property file which is an array. I assume this array can be attatched directly to the Workitem if assigned to the msg.files property.
function node Prepare WI:
After inspecting the URL response, I noticed multiple headers that are presumably designed to ensure browser-like interaction for the request. Please correct me if I’m wrong, but this suggests that the URL is not intended to be used for retrieving the file content programmatically.
Hi,
I have created an example for adding files to workitems in NodeRED.
Main thing: msg.files should contain a list of files.
The file itself should be a bufffer.
I am sorry, I was too quick. I thought you had the data already in NodeRED.
I need to dive into that with the form. (it has been years since I last used forms, but I should have an example somewhere).
I’ll take a look, but it may take me some time as deadlines at work are approaching rappidly…
I was curious about this one as well, and tried a small workflow, and I think I’m also missing something.
What I got working, although it’s clearly a workaround, was:
Upload the file through the form.
Get the name property out of the payload (the one with the guid in it, not the original name), query the files collection for the id of the object with that uniqueName, and add that to the workitem. After that, in OpenRPA/agent, fetch it using the id and GetFile/download.
What I tried that didn’t work:
Use download node in NodeRed to get the file as a buffer to pass it to workitem → access denied (why? I don’t know - it seems illogical, as all the ACL seem fine)
Use GetFile in OpenRPA with UniqueName as the name → file not found (it can only download by the non-unique filename, and that is not what’s needed in most cases)
I’m pretty sure I’m missing something, but that feels like a very roundabout way of doing it, and I’m pretty sure there should be a shorter path to this that I don’t know.
Exactly my thoughts as well. It seems impossible to use the URL directly from the file component as there are so many headers required on the download link.
That was also the only workaround i could get to work, but it does seem a bit of a detour as it feels like the informaiton should be right there, easy to access and pass, at least having the file _id property be available.
I’m currently working on a solution to make this proces a bit more stream-lined
Thanks Peter, the subflow looks nicely done (also learned a thing or two about designing more readable subflows thanks to this ).
Question though - what was the reason for the static delay at the start?
One thing to note, is that using this method to attach the file to wi seems to be duplicating the file - the form uploads it, then the wi submission uploads it again from the buffer, so that needs to be potentially cleaned out in the calling workflow (f.e. deleting the original file after adding the wi, to avoid clutter).
That said, all of this would be much easier if the upload form would be adding the file _id to its payload (which could be used in download file directly as a unique identifier).
you are welcome, im glad to contribute to this awesome forum.
Im glad you mention the bit about adding the file to the workflow it took me a while to figure out where this extra file came from i didnt decide on removing the extra file but yes it is not convinent to have a dupe.
but in my opinion i think it would make a lot more sense to have a build in property on the add workitem node like (attach files from openflow using uniqueue names) so that the dupes could bed avoided
also the delay is just to quickly reflect the nodes status when activated. hope it makes sense
indeed totally agree with the _id that was what i attempted to begin with
In OpenFlow, i check if the _id and filename exists in the array,
but since grpc changes that to id i’m unsure if that logic works right now, with NEW workitems …
I need a little time to setup a reproduction of this, but then i can make sure that you CAN add an existing uploaded file to a work item, so you don’t get duplicates.
That would be very convientient and a great feature. But we also need to make sure that the unique identifier is accessible through the compenent file’s api in the openflow form
Ah, yeah, forgot to address that.
So when you upload a file on a form, it needs to be unique, but since the form does not have full context, AND can be reloaded multiple times, I use forms.io’s id in the database. That is why you need to find the file by searching the file(s) by searching for uniquename in the file(s) metadata … field