# Upload File

> `UiPath.MicrosoftOffice365.Activities.Files.UploadFile`

`UiPath.MicrosoftOffice365.Activities.Files.UploadFile`

## Description

Uses the Microsoft Graph [Resumable upload](https://docs.microsoft.com/en-us/graph/api/driveitem-createuploadsession?view=graph-rest-1.0) API to upload a local file to your OneDrive or SharePoint account.

### Scopes

This activity requires the following scopes:

* Sites.ReadWrite.All

## Project compatibility

Windows - Legacy | Windows

## Configuration

#### In the body of the activity

* **File to upload** - The file to be uploaded. Select **Browse** ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/activities-image-browse_files-1431ef7d.png) next to the field, and then browse to and select the file. This property supports `String` variables and string formatted values.
  :::note
  Starting with v2.0.1, the (`&`) and (`#`) characters in file names are replaced with an underscore (`_`). This behavior is caused by the Graph API.
  :::
* **Destination folder** - The folder where to upload the filer. If left blank, the file is uploaded in the OneDrive root folder. This property supports `String` variables and string formatted values.
* **New name (optional)** - The new name of the file or folder after it is uploaded. This property supports `String` variables and string formatted values.
* **Conflict behavior** - Indicates the conflict resolution behavior in case a file with the same name already exists. Select one of three options: **Replace**, **Fail**, **Rename**. The default value is **Replace**.
  :::note
  You can save files or folders for later use in the automation using the [Get File/Folder](https://docs.uipath.com/activities/other/latest/productivity/office365-get-item-info) activity.
  :::

#### Properties panel

**Common**

* **DisplayName** - The display name of the activity in the Designer panel. This property supports `String` variables and string formatted values.

**Input**

* **Checkin** - Indicates whether to checkin the file after upload. If you use SharePoint libraries with version control, the uploaded file becomes visible only if you enable this checkbox. Boolean value.
* **Metadata** - The metadata to associate with the uploaded file (it works only for a file stored in a SharePoint Document Library). It should contain two columns, the first one representing the display name of the field (String) and the second its value. This field only supports `DataTable` values.
* Check the rest of the options in the body of the activity.
  :::note
  You must use the display name of the Document Library column in the `DataTable` object passed to the **Metadata** parameter.
  :::

**Misc**

* **Private** - If selected, the values of variables and arguments are no longer logged at Verbose level. This field supports Boolean values.

**Options**

* **Account** - The ID or User Principal Name for the user who owns the OneDrive. This parameter must be set for **ApplicationIdAndSecret** and **ApplicationIdAndCertificate** authentication types.

**Output**

* **Reference as** - The uploaded file as a `DriveItem`. Required if you plan to use the output data in subsequent activities. Enter a `DriveItem` variable that is different than the one used in the **Destination** property.

## How it works

The following steps and message sequence diagram is an example of how the activity works from design time (i.e., the activity dependencies and input/output properties) to run time.

1. Complete the steps.
2. Add the [Microsoft Office 365 Scope](https://docs.uipath.com/activities/other/latest/productivity/microsoft-office-365-scope) activity to your project.
3. Add an activity or run an external process that outputs a `DriveItem` object (e.g., [Find Files And Folders](https://docs.uipath.com/activities/other/latest/productivity/office365-find-files-and-folders)).
4. Add the **Upload Item** activity inside the **Microsoft Office 365 Scope** activity.
5. Enter values for the Input properties.
6. Create and enter a `DriveItem` variable for your Output property.
7. Run the activity.
   * Your input property values are sent to the [Upload](https://docs.microsoft.com/en-us/graph/api/driveitem-createuploadsession?view=graph-rest-1.0) API.
   * The API returns the `DriveItem` value to your output property variable.

![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/activities-docs-image-185462-e00300a4.webp)
