SharePoint - Upload Files

Declaration

<AMSHAREPOINT ACTIVITY="upload_files" SESSION="text" SOURCE="text" 
DEST="text*.*" RESULTDATASET="text" SUBFOLDERS="YES/NO" 
KEEPFOLDERSTRUCT="YES/NO" />

Description: Uploads one or more local files to a SharePoint library. To specify more than one file, use wildcard characters (e.g., * or ?). To specify multiple files or wildcard masks, separate them with a pipe character (e.g., sourceFolder/*.txt|sourceFolder/*.bak).

Practical Usage

Ideal for automated transmission of files to a SharePoint site.

Connection Parameters

Property

Type

Required

Default

Markup

Description

Connection

---

---

---

---

Indicates where this activity's SharePoint credentials should originate from. This is a visual parameter used only during design-time, thus, contains no properties or markups. The available options are:

  • Host - Specifies that a custom set of credentials will be entered for this activity. This option is normally selected if only a single SharePoint activity is required to complete the task.

  • Session - Specifies that credentials should derive from a session created in a previous Create session step. This allows several activities to be linked to a specific session, eliminating redundancy. Multiple sessions can exist within a single task, allowing several SharePoint operations to be automated simultaneously.

Session

Text

Yes if Connection set to Session

SharePoint

Session1

SESSION="mySession1"

The name of the session to associate with this activity. This parameter is active only if the Connection parameter above 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 set to Host

SharePoint 2010

  1. VERSION="sharepointonline"

  2. VERSION="sharepoint2010"

  3. VERSION="sharepoint2007"

The SharePoint version to associate with this activity. The available options are:

  • SharePoint Online - A cloud-based service, hosted by Microsoft as an alternative to installing and deploying SharePoint Server on premises.

  • SharePoint 2010 and newer (default) - SharePoint version 2010 or newer - includes SharePoint Foundation 2010/2013 and SharePoint Server 2010/2013.

  • SharePoint 2007 and older - SharePoint version 2007 or older - includes Windows SharePoint Services (WSS) v3 edition and Microsoft Office SharePoint Server 2007 (MOSS 2007) edition.

NOTE:  Some SharePoint activities are only supported in SharePoint 2010 or newer.

Site

Text

Yes if Connection set to Host

(Empty)

SITE="http://myServer/tech"

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

  1. AUTHTYPE="form"

  2. AUTHTYPE="anonymous"

  3. AUTHTYPE="basic"

  4. AUTHTYPE="digest"

  5. AUTHTYPE="ntlm"

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.

  • Default (default) - Compatible withSharePoint 2010 or newer.

  • Basic - Compatible with  all SharePoint versions.

  • Form - Compatible withSharePoint 2010 or newer.

  • Anonymous - Compatible withSharePoint 2010 or newer.

  • Digest - Compatible with  SharePoint 2007 or older.

  • Proprietary - Compatible with  SharePoint 2007 or older.

  • None - Compatible with  SharePoint 2007 or older.

  • NTLM - Compatible with  SharePoint 2007 or older.

Username

Text

Yes

(Empty)

USERNAME="theUserName"

A valid SharePoint username. 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 the username entered above. 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 that 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 certificate

Yes/No

No

No

IGNOREINVALIDCERTIFICATE="yes"

If set to YES, specifies that invalid server certificates that are detected will be automatically ignored. Set to NO 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

Default

  1. PROXYTYPE="none"

  2. PROXYTYPE="http"

The type of proxy required for SharePoint connections that pass through a proxy server. The available options are:

  • System default (default) - Points to the default proxy used by the system.

  • None - No proxy authentication required.

  • HTTP - Proxytype is HTTP.

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 password

Text

No

(Empty)

PROXYPASSWORD="encrypted"

The proxy password to authenticate with. This parameter is available only if the Use Authentication parameter is enabled.

Proxy port

Number

No

808

PROXYPORT="8080"

The port that should be used 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.

File Parameters

Property

Type

Required

Default

Markup

Description

Local file(s)

Text

Yes

(Empty)

  1. SOURCE="c:\foldername\file.txt"

  2. SOURCE="c:\foldername\*.txt"

  3. SOURCE="c:\folder\*.txt|c:\folder\*.doc"

The source file(s) to upload. This can be a fully qualified UNIX style path and filename (preferred) or a single file. Wildcards (e.g., *.* 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  (e.g., *.txt|*.bak).

Remote file(s)

Text

Yes

(Empty)

  1. DEST="/foldername/file.txt"

  2. DEST="/foldername/*.txt"

  3. DEST="file.txt"

The destination folder and (optionally) filename of the file(s) to upload. This can be a fully qualified path or a filename. Folders that do not exist will be automatically created at runtime.

Click the folder icon to use the SharePoint Browser, a user-friendly interface that enables connection to a SharePoint site 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 Datasets below.

File Options Parameters

Property

Type

Required

Default

Markup

Description

Exclude mask

Text

No

(Empty)

  1. EXCLUDE="*.txt"

  2. EXCLUDE="*.txt|*.bak"

Causes this activity to omit any files matching the mask(s) specified. Filenames or wildcard masks (e.g., * or ?) may be used. Multiple entries may be specified by separating them with the pipe ("|") symbol (e.g., *.txt|*.bak).

Regular expression

Yes/No

No

No

RE="YES"

If set to YES, 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 set to NO (default) the value is interpreted as plain, readable text.

Only if newer than

Date

No

(Empty)

ISNEWERTHAN=

"%DateSerial(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 set to YES, matching destination files will be overwritten. If set to NO, matching files will not be overwritten, however, an error will occur as a result.

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 set to YES, archive attribute will be turned off. If set to NO (default), archive attribute will be turned on.

Include subfolders

Yes/No

No

No

SUBFOLDERS="YES"

If set to YES, specifies that, if present, sub-folders should be searched for files matching the mask specified in the Remote file(s) parameter. The default value is NO.

Preserve folder structure

Yes/No

No

No

KEEPFOLDERSTRUCT="YES"

If set to YES, 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 file(s) parameter. The default value is NO. This option is available only if the Include subfolders parameter is set to YES.

File Attributes Parameters

Property

Type

Required

Default

Markup

Description

Attributes

Text Options

No

(Empty)

ATTRFILTER="+R+A-H"

(compress read-only & archive files but not hidden files)

This group of settings causes the activity to filter which files are transferred based on their attributes. In visual mode, a group of controls are provided to assist in the selection. In markup mode, a single text item is specified that contains the attributes of the files you wish to transfer. Available Options are:

  • R—Read-only: Specifying "+R" causes files with this attribute turned on to be included, "-R" causes files with this attribute turned off to be included, not specifying the letter (default) causes this attribute to be ignored.

  • A—Archive: Specifying "+A" causes files with this attribute turned on to be included, "-A" causes files with this attribute turned off to be included, not specifying the letter (default) causes this attribute to be ignored.

  • S—System: Specifying "+S" causes files with this attribute turned on to be included, "-S" causes files with this attribute turned off to be included, not specifying the letter (default) causes this attribute to be ignored.

  • H—Hidden: Specifying "+R" causes files with this attribute turned on to be included, "-H" causes files with this attribute turned off to be included, not specifying the letter (default) causes this attribute to be ignored.

  • C—Compression: Specifying "+C" causes files with this attribute turned on to be included, "-C" causes files with this attribute turned off to be included, not specifying the letter (default) causes this attribute to be ignored.

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

Date

The destination path and filename of the file being uploaded.

theDataset.LocalFileDate

Text

The current date of the source file being uploaded. The date format will be similar to 11/12/2014 09:18:08 AM.

theDataset.LocalFileSize

Text

The size (in KB) of the source file being uploaded.

theDataset.LocalFileName

Text

The full path and filename 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.

Description: This sample task demonstrates the use of sessions as well as ability to upload files to a SharePoint site.

This sample is for AML viewing purposes only. In order for the task to work, it must be modified to fit your SharePoint credentials.

<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_files" 
SESSION="SharePointSession1" SOURCE="C:\Logs\Upload\*.*" 
DEST="MyLibrary/*.*" RESULTDATASET="uploadDataset" 
SUBFOLDERS="YES" KEEPFOLDERSTRUCT="YES" />
<AMSHAREPOINT ACTIVITY="end_session" 
SESSION="SharePointSession1" />