SharePoint - Upload file(s) |
Declaration
<AMSHAREPOINT ACTIVITY="upload_file" SESSION="text" UPLOADTYPE="single" SITE="text" VERSION="text (options)" AUTHTYPE="text (options)" USERNAME="text" PASSWORD="text (encrypted)" DOMAIN="text" IGNOREINVALIDCERTIFICATE="YES/NO" CERTIFICATE="text" PROXYTYPE="text (options)" PROXYSERVER="text" PROXYPORT="number" PROXYUSERNAME="text" PROXYPASSWORD="text (encrypted)" TIMEOUT="number" UPLOADTYPE="text (options)" SOURCE="text" DEST="text" URL="text" OVERWRITE="YES/NO" RESULTDATASET="text" SUBFOLDERS="YES/NO" KEEPFOLDERSTRUCT="YES/NO" OVERWRITE="YES/NO" MATCHCASE="YES/NO" EXCLUDE="text" RE="YES/NO" ISNEWERTHAN="text" ISOLDERTHAN="text" ARCHIVETURNOFF="YES" ATTRFILTER="text (options)"><METATAGCONSTRUCT NAME="text" VALUE="text" /></AMSHAREPOINT>
Description
Uploads one or more local files to a SharePoint library. To specify more than one file, use wildcard characters (for example, * or ?). To specify multiple files or wildcard masks, separate them with a pipe character (for example, sourceFolder/*.txt|sourceFolder/*.bak).
Practical Usage
Ideal for automated transmission of files to a SharePoint site.
Parameters
Connection
Property | Type | Required | Default | Markup | Description |
---|---|---|---|---|---|
Connection | --- | --- | --- | --- | Indicates
where this activity's SharePoint credentials originate
from. This is a visual parameter used only during design-time,
thus, it contains no properties or markups. The available options
are:
|
Session | Text | Yes, if Connection is set to Session |
SharePointSession1 |
SESSION="mySession1" |
Specifies the name of the session to associate with this activity. This parameter becomes active and is required if the Connection parameter is set to Session. If the Connection parameter is set to Host, this parameter is ignored and the remainder of the parameters specified below becomes active. |
Version | Text (options) | Yes, if Connection is set to Host | SharePoint 2010 and newer |
|
Specifies the
SharePoint version to associate with this activity. The available
options are:
NOTE: Some SharePoint activities are only
supported in SharePoint 2010 or newer. |
Site | Text | Yes, if Connection is set to Host | (Empty) | SITE="http://myServer/tech" | Specifies the SharePoint site to access. A SharePoint site is a collection of pages, site templates, lists, and libraries configured for the purpose of achieving an express goal. |
Authentication type | Text (options) | No | Default |
|
Specifies the
method of authentication to utilize. Authentication types vary
depending on the SharePoint version. Different parameters become
active depending on which authentication method is selected. Below
lists available authentication methods and their compatibility.
|
Username | Text | Yes | (Empty) | USERNAME="theUserName" | A valid SharePoint username to authenticate with the SharePoint site. This parameter may or may not be active depending on which option is selected under the Authentication type parameter. |
Password | Text | Yes | (Empty) | PASSWORD="encryptedText" | A valid SharePoint password to authenticate with the Username parameter. This parameter may or may not be active depending on which option is selected under the Authentication type parameter. |
Domain | Text | Yes | (Empty) | DOMAIN="myServer" | The domain the user belongs to. This parameter may or may not be active depending on which option is selected under the Authentication type parameter. |
Certificate | Text | No | (Empty) | CERTIFICATE="C:\Temp\file.cer" | The (DER encoded) certificate to use for SharePoint authentication. This parameter may or may not be active depending on which option is selected under the Authentication type parameter. |
Ignore invalid server certificate | Yes/No | No | No | IGNOREINVALIDCERTIFICATE="yes" | If selected, specifies that invalid server certificates that are detected will be automatically ignored. Disabled by default. |
Timeout (seconds) | Number | No | 600 | TIMEOUT="500" | The total number of seconds allowed to connect to the SharePoint server before a timeout error is generated. The default value is 600 seconds. |
Proxy type | Text (options) | No | System default |
|
The
type of proxy required for SharePoint connections that pass through
a proxy server. The available options are:
|
Use authentication | --- | --- | --- | --- | If enabled, specifies that proxy authentication is required, enabling authentication-based parameters (disabled by default). This is a design-time parameter, therefore, contains no properties or markups. It is active only if the Proxy type parameter is set to HTTP. |
Proxy server | Text | No | (Empty) | PROXYSERVER="proxy.host.com" | The host name (server.domain.com) or IP address (xxx.xxx.xxx.xxx) of the proxy server. This parameter is available only if the Proxy type parameter is set to HTTP. |
Proxy username | Text | No | (Empty) | PROXYUSERNAME=username | The proxy username to authenticate with. This parameter is available only if the Use Authentication parameter is enabled. |
Proxy port | Number | No | 808 | PROXYPORT="8080" | The proxy port to connect to the proxy server. This parameter is available only if the Proxy type parameter is set to HTTP. The default value is 808. |
Proxy password | Text | No | (Empty) | PROXYPASSWORD="encrypted" | The proxy password to authenticate with. This parameter is available only if the Use Authentication parameter is enabled. |
File
Property | Type | Required | Default | Markup | Description |
---|---|---|---|---|---|
File | Text (options) | Yes | Multiple file(s) |
|
Specifies the quantity of files to upload to the SharePoint site. The available options
are:
|
Source | Text | Yes | (Empty) |
SOURCE="/my/personal/file.txt" |
Specifies the source file to upload. This parameter becomes active and is required if the File parameter is set to Single file. |
Destination (server relative URL) | Text | Yes | (Empty) |
URL="/dest/location/file.txt |
Specifies the destination URL in which to upload the file to. This parameter becomes active and is required if the File parameter is set to Single file. Click the folder icon to use the SharePoint Browser, a user-friendly interface that enables you to connect to a SharePoint site in order to view or select specific contents such as files, folders and attachments. |
Overwrite | Yes/No | No | No | OVERWRITE="YES" | If selected, files with the same name as the uploaded file will be overwritten. If disabled, this step fails with an error if files with the same name are found. This parameter becomes active if the File parameter is set to Single file and is unselected by default. |
Local file(s) | Text | Yes | (Empty) |
|
Specifies the source files to upload. This can be a fully qualified UNIX style path and file name (preferred) or a single file. Wildcards (for example, * or ?) may be used to upload files matching a certain mask. Multiple file and/or file masks may be specified by separating the entries with a pipe (|) symbol (for example, *.txt|*.bak). This parameter becomes active and is required if the File parameter is set to Multiple file(s). |
Remote file(s) | Text | Yes | (Empty) |
|
Specifies the
destination folder and (optionally) file name of the files to
upload. This can be a fully qualified path or a file name. Folders
that do not exist will be automatically created at runtime. This parameter becomes active and is required if the File parameter is set to Multiple file(s). Click the folder icon to use the SharePoint Browser, a user-friendly interface that enables connection to a SharePoint site in order to view or select specific contents. |
Create and populate upload dataset | Text | Yes | (Empty) | RESULTDATASET="theDownloadInfo" | The name of the dataset to create and populate with information regarding the upload that took place. For more details, see the Datasets section below. |
Metatag(s) | Text | No | (Empty) | METATAGCONSTRUCT NAME="Category" VALUE="New" | Specifies the metadata to include with the files to upload for columns available on the SharePoint site. Metatags can be set for more than one column at a time. This parameter becomes active if the File parameter is set to Multiple file(s). |
File Options
Property | Type | Required | Default | Markup | Description |
---|---|---|---|---|---|
Exclude mask | Text | No | (Empty) |
|
Causes this activity to omit any files matching the masks specified. Filenames or wildcard masks (for example, * or ?) may be used. Multiple entries may be specified by separating them with the pipe (|) symbol (for example, *.txt|*.bak). |
Regular expression | Yes/No | No | No | RE="YES" | If selected, specifies that the value entered in the Exclude mask parameter is interpreted as a regular expression (also referred to as regex or regexp) which provides a concise and flexible means for matching strings of text. If disabled (default), the value is interpreted as plain, readable text. |
Only if newer than | Date | No | (Empty) | ISNEWERTHAN="%DateSeria(2001,10,12 + TimeSerial(00,00,00)%" | If enabled, causes this activity to only act on files that are newer than the date/time specified. Click the Custom button to select from a list of pre-defined date parameters. Enable the Expression option to allow entry of a date/time expression. If this parameter is disabled (default), file "newer than" dates are ignored. |
Only if older than | Date | No | (Empty) | ISOLDERTHAN="%DateSerial(2001,10,12) + TimeSerial(00,00,00)%" | If enabled, causes this action to only act on files that are older than the date/time specified. Click the Custom button to select from a list of pre-defined date parameters. Enable the Expression option to allow entry of a date/time expression. If this parameter is disabled (default), file "older than" dates are ignored. |
Overwrite if exists | Yes/No | No | No | OVERWRITE="YES" | If selected, matching destination files will be overwritten. If disabled, matching files will not be overwritten, however, an error will occur as a result. |
Include subfolders | Yes/No | No | No | SUBFOLDERS="YES" | If selected, specifies that, if present, sub-folders should be searched for files matching the mask specified in the Remote files parameter. This parameter is to NO by default. |
Preserve folder structure | Yes/No | No | No | KEEPFOLDERSTRUCT="YES" | If selected, specifies that sub-folders found in the source folder should be created in the destination folder and source files should be copied into their respective folders rather than directly into the root of the target folder specified in the Local files parameter. The default value is NO. This option is available only if the Include subfolders parameter is selected. |
Match Case | Yes/No | No | No | MATCHCASE="YES" | Indicates whether the properties set within this activity should be case sensitive in relation to the FTP server. The default value is NO. |
Turn archive attribute off | Yes/No | No | No | ARCHIVETURNOFF="YES" | If selected, archive attribute is turned off. If disabled (default), archive attribute is turned on. |
File Attributes
Property | Type | Required | Default | Markup | Description |
---|---|---|---|---|---|
File attributes | Text (options) | No | Doesn't matter | ATTRFILTER="+R+A-H" (compress read-only & archive files but not hidden files) | Instructs
the activity to filter which files to act on, based on whether
the file's original attribute settings match the attribute settings
specified in this parameter. In Task Builder's visual mode, drop-down boxes are provided within the activity's settings
to assist in the selection of attribute settings. In Task Builder's AML mode,
a text item must be entered that contains the original
attribute mask of the files you wish to affect. For example, if Read-only
attribute is set to Off
(in visual mode) or -R (in AML mode) , only source files with the Read-only attribute
turned off are affected. Source files with Read-only attribute turned
on will be ignored. The available options
are:
|
Additional Notes
Datasets
A dataset is a multiple column, multiple row container object where every column represents a particular variable, and each row corresponds to a given member of the dataset in question. This activity creates and populates a dataset containing specific fields (rows) in addition to the standard dataset fields. The table below describes these fields (assuming the dataset name assigned was theDataset).
Name | Type | Return Value |
---|---|---|
theDataset.Error | Text | A textual description of the error that occurred (if any). If no errors occurred during the download step, this dataset will remain empty. |
theDataset.UploadResult | True/False | The upload result. The value is either True or False. |
theDataset.SharePointFileName | Text | The destination path and file name of the file being uploaded. |
theDataset.LocalFileDate | Date | The current date of the source file being uploaded. The date format will be similar to 11/12/2020 09:18:08 AM. |
theDataset.LocalFileSize | Text | The size (in KB) of the source file being uploaded. |
theDataset.LocalFileName | Text | The full path and file name of the source file being uploaded. |
Example
- The sample AML code below can be copied and pasted directly into the Steps Panel of the Task Builder.
- Parameters containing user credentials, files, file paths, and/or other information specific to the task must be customized before the sample code can run successfully.
Description
This sample task demonstrates the use of sessions as well as Automate's ability to upload files to a SharePoint site.
<AMSHAREPOINT ACTIVITY="create_session" SITE="https://netauto.sharepoint.com/sites/dev" VERSION="sharepointonline" USERNAME="jp@networkautomation.com" PASSWORD="AM48swl5oDSFYhKASv/xC8SyB1QuzwD97yoaME" SESSION="SharePointSession1" />
<AMSHAREPOINT ACTIVITY="upload_file" SESSION="SharePointSession1" UPLOADTYPE="multiple" SOURCE="C:\Logs\Upload\*.*" DEST="MyLibrary/*.*" RESULTDATASET="uploadDataset" SUBFOLDERS="YES" KEEPFOLDERSTRUCT="YES" />
<AMSHAREPOINT ACTIVITY="end_session" SESSION="SharePointSession1" />