Studio Web - how to download a file and upload it to OneDrive

Studio Web - how to download a file and upload it to Cloud

This small Studio Web tutorial will teach you how to download a file from a website and do some things with it - in this case, upload it to a OneDrive folder.

While the experience of downloading the files will be improved with the introduction of dedicated activities, this small tutorial will teach you how to do that in the meantime.

The end result:

Automation steps

1. Use Browser activity

To start, we will open a webpage that contains a clickable link to our file. In our case, we will make use of this sample page:
https://forum.uipath.com/pub/sample-file-to-download

image

2. Click activity

Next step is to click on the link to download the file
image

3. Delay

A simple delay to make sure the file is downloaded.
image
For more advanced users, this can be replaced with a Do While loop that will periodically check if the file is already there, rather than using a fixed delay.
But for this example we will keep it simple.

4. Path exists - the :star: of this simple use case

The activity Path exists allows you to input any local file path and create a file variable out of it when it exists. Otherwise, it would be difficult to upload your file in the next step.

image

The expression to fetch the file is slightly long, but this will also be improved in the future :slight_smile:

Directory.GetFileSystemEntries((Directory.GetDirectoryRoot(Directory.GetCurrentDirectory)+"tmp/home/Downloads"), "*.txt", SearchOption.AllDirectories)(0)

Please make sure to insert this code snippet with the Open Expression Editor:
image

5. Upload file to OneDrive

The last step is quite simple. We take the output of the Path Exists activity and we provide it to the Upload file to OneDrive activity. And after setting up the connection and the target folder, we’re done! :slight_smile:
image

The project file

Feel free to import the project and give it a go :slight_smile:
Download a file from the internet and upload it to Cloud.uip (28.2 KB)

4 Likes