How to pass file to orchestrator queue

excel
queue

#1

Hi, I would like to insert excel files from one specific location to orchestrator queues using AddQueue item. I can able to pass data from excel to queue or any other data without any issues but how I can pass file as it is to orchestrator queues ? Any help ? Thanks in advance.


#2

Hi,

Would it help if you would pass the file’s path and then when you process the item it retrieves the file and processes again the information there?


#3

Thanks for the reply.

We have a requirement that , multiple users can place the input files for robot and users should not delete the files which are placed by other users accidentally.

It is bit difficult To achieve this requirement but if we send the file to orchestartor queue then other users can not delete the file from input location.


#4

I’m trying to achieve the same thing.

My idea was to read all the bytes from the file into a byte[] and add that, together with the files name to the QueueItem, which is then stored in the orchestrator.

The part where I am stuck is where I want to write the file back to disk from the queue. There I need to convert the SpecificContent(“File”) (of type object) to type Byte[] to be able to write it using the Invoke method.

I hope that helps you out, and possibly you know how to convert object to byte[]?


#5

After some research and testing I found the following:

If you load a file into a byte [] by using either creating a custom activity, or using the invoke method activity, and then add this byte[] to a QueueItem.ItemInformation, it will be encoded into the queue as a base64string.

To retrieve it from the queue and store it to disk, you can take the QueueItem.SpecificContent and store it to disk by first applying object ToString, then convertfrombase64 (again using either a custom activity or by using the invoke method), which turns it into a byte array, and finally do a writeallbytes to write it to disk.

Note: I have no idea if there is a limitation on size of items in thequeue, but got storing a file and later on retrieving it from the queue working like this. In addition you might want to store the name of the file into the queue as well, such that you can save it with the original filename


#6

Can you walk me through how you made it work with the Invoke Method?


#7

DISCLAIMER: I discussed with the UIPath Team and they strongly discourage uploading complete files as strings to the queue. They suggested moving the file to a shared folder as an alternative.
END OF DISCLAIMER

However in case you really want to upload a file to queue and take it off the queue, this would be the way to do so, I attached a robot that uploads a dummyfile to the queue, for each line in the file, and on dequeue downloads the file from queue to disk and attaches it to an email.
:Main.zip (13.8 KB)

Note that the email sending is missing credentials for obvious reasons :wink: