Download File activity failed to capture the file output

This question is to be answered by UiPath architect team.
@developers - please excuse.

Issue - The ;download file’ activity is randomly (or occasionally) failing to capture the output file. We did all the possible ways to prevent this error. Interestingly, the file has been downloading into download folder and failing to capture the actual output file and giving an output as “xxxxx.tmp” file.

fyi - we are using the licensed version 20.4.3

First - if you are an enterprise license user and want an answer from the uipath architect team, you should contact them directly rather than using the forums.

Second - the ‘download file’ activity is meant for salesforce only since it’s part of the uipath.salesforce.activites library. If you are using it outside of salesforce it may not behave as expected.

Third - I would propose a workaround. I know you said you tried all the ways possible to prevent the error, but why don’t you instead put in some error handling in case it does happen rather than trying to prevent it? This could be something as simple as using a retry loop with the condition is true: outputfile.endswith(“.tmp”) and inside the retry loop you just have an assign activity that is grabbing the latest downloaded file within your expected download directory

Thank you Dave!

First - yes, we can do that.

Second - its not an activity for salesforce. Its an activity (UiPath.Core.Activities.GetLastDownloadedFile) we used to download a file on web.

Third - we are not letting the bot to continue when an error throws up in error handling. what is the point of retrying the same when activity is not stable. In fact, the activity has failed though it was retried.

Oh ok i’m a version or two behind in my enterprise license so that activity isn’t available, sorry about that.

As for the “third” response - why don’t you let the bot continue? I’ve used the workaround I proposed for all of my activities since we started using uipath a few years ago and it’s never been a problem, even when there are extreme network slowdowns. It guarantees that the file is completely finished downloading before continuing the workflow

Here it’s not the problem with downloading the file. As I said in my post, the file has been downloading into the download folder and failing to capture the actual output file and giving an output as “xxxxx.tmp” file

I understand. If you watch the folder during processing i guarantee you will see a random file name ending in .tmp appear briefly in the folder (make sure you can view hidden files). This happens every single time you download a file.

The reason that happens is because the activity is moving too quickly for your network - therefore it sees the .tmp file that gets created in windows for every file you download and is assuming that is the completed file you want. However, you don’t want the .tmp file, you want the actual completed file (.xlsx, .pdf, .jpg, whatever). My proposed solution is to check the output you are getting from the download file activity. If it ends with .tmp then you have the temporary file and you should check the folder again to see if the download has finished. Do this with a retry loop and play around with the time settings (ideally it is coming from your config instead of hardcoded) as different file sizes and network speeds can affect how long the download will take.

At my company, our standard retry timer is to wait 5 seconds between tries and the standard retry counter is set to retry 10 times. This generally takes ~1min even though 5x10 is 50 seconds. If the file hasn’t downloaded by that time we want an error thrown as something is wrong. If you are downloading extremely small files you may want to adjust downward. If you are downloading extremely large files you may wish to adjust upward.

we can not track the “.tmp” file which would be in guid (eg. 228cc455-44e5-47b0-983b-1daf9c6f6ccb.tmp) . How can we search a file w/o knowing the file name. There is always a possibility to have multiple files from different processes at the same time.

The download file activity has a good feature to capture the exact file if it is works.

step 1 - download the file with ‘download file activity’ save as string variable called myFile

step 2 - validate that the output from ‘download file activity’ worked. Do this with a retry activity surrounding a single if activity.
Retry loop condition: is true: myFile.EndsWith(".tmp")
If Condition: myFile.EndsWith(".tmp")
True side: assign MyFile = String.Join("", Directory.GetFiles(YourFolderPath).OrderByDescending(Function(x) New FileInfo(x).CreationTime).Take(1) )
False side: leave this blank

Now you will have validated that your file is not running into the problem where it is assigning the temporary value accidentally. If it does get assigned, then it will retry grabbing the file (regardless of what it is called) until you get it. Like I stated previously, you are grabbing the last file in the folder - you aren’t specifying a specific file name.

Thank you Dave for your inputs.

We have tried a similar thing with do while activity. its a good thought, but risky.

UiPath doc says:

I think there are going to correct this in the coming version.

May I ask what the risk is? It is data validation and it should be done on all inputs you receive to reduce risk.

And the screenshot is not saying anything will be changed other than the name of the activity

Risk - There is always a possibility to have multiple files from different processes at the same time.

Not only activity name change, they are using a Delegate method to check whether the file is completed or not. I have checked 20.10.1 preview version in community edition. Here is the screenshot.

image

Hi Dave, you seem to have something working here… I have a bit of a problem where i am downloading files from the URL from an excel sheet, i scrapped a website and got Documents and URL portion and saved it in the excel.

Now i am reading that excel sheet and in the portion of URL it is not only getting pdf, it has other formats, how can i download any format? both the URL and Documents are saved on a variables.

What issue are you running into? I’ve never actually used the ‘download file’ activity, as I don’t seem to have that in my version of studio for some reason. I usually use the ‘http activity’ which is part of the uipath.web.activities package

However, I would imagine that you can just make sure the file extension is included at the end of the file name and it should download them all just fine.

My issue is i am unable to save files to my choice, i only have an option of choosing on file type eg pdf or word, but not all