Skip to content

spo file add

Uploads file to the specified folder

Usage

spo file add [options]

Options

Option Description
--help output usage information
-u, --webUrl <webUrl> The URL of the site where the file should be uploaded to
-f, --folder <folder> Site-relative or server-relative URL to the folder where the file should be uploaded
-p, --path <path> Local path to the file to upload
-c, --contentType [contentType] Content type name or ID to assign to the file
--checkOut [checkOut] If versioning is enabled, this will check out the file first if it exists, upload the file, then check it in again
--checkInComment [checkInComment] Comment to set when checking the file in
--approve [approve] Will automatically approve the uploaded file
--approveComment [approveComment] Comment to set when approving the file
--publish [publish] Will automatically publish the uploaded file
--publishComment [publishComment] Comment to set when publishing the file
-o, --output [output] Output type. json|text. Default text
--verbose Runs command with verbose logging
--debug Runs command with debug logging

Remarks

This command allows using unknown properties. Each property corresponds to the list item field that should be set when uploading the file.

Examples

Adds file MS365.jpg to site https://contoso.sharepoint.com/sites/project-x in folder Shared Documents

spo file add --webUrl https://contoso.sharepoint.com/sites/project-x --folder 'Shared Documents' --path 'C:\MS365.jpg'

Adds file MS365.jpg to site https://contoso.sharepoint.com/sites/project-x in sub folder Shared Documents/Sub Folder 1

spo file add --webUrl https://contoso.sharepoint.com/sites/project-x --folder 'Shared Documents/Sub Folder 1' --path 'C:\MS365.jpg'

Adds file MS365.jpg to site https://contoso.sharepoint.com/sites/project-x in folder Shared Documents specifying server-relative folder url

spo file add --webUrl https://contoso.sharepoint.com/sites/project-x --folder '/sites/project-x/Shared Documents' --path 'C:\MS365.jpg'

Adds file MS365.jpg to site https://contoso.sharepoint.com/sites/project-x in folder Shared Documents with specified content type

spo file add --webUrl https://contoso.sharepoint.com/sites/project-x --folder 'Shared Documents' --path 'C:\MS365.jpg' --contentType 'Picture'

Adds file MS365.jpg to site https://contoso.sharepoint.com/sites/project-x in folder Shared Documents, but checks out existing file before the upload

spo file add --webUrl https://contoso.sharepoint.com/sites/project-x --folder 'Shared Documents' --path 'C:\MS365.jpg' --checkOut --checkInComment 'check in comment x'

Adds file MS365.jpg to site https://contoso.sharepoint.com/sites/project-x in folder Shared Documents and approves it (when list moderation is enabled)

spo file add --webUrl https://contoso.sharepoint.com/sites/project-x --folder 'Shared Documents' --path 'C:\MS365.jpg' --approve --approveComment 'approve comment x'

Adds file MS365.jpg to site https://contoso.sharepoint.com/sites/project-x in folder Shared Documents and publishes it

spo file add --webUrl https://contoso.sharepoint.com/sites/project-x --folder 'Shared Documents' --path 'C:\MS365.jpg' --publish --publishComment 'publish comment x'

Adds file MS365.jpg to site https://contoso.sharepoint.com/sites/project-x in folder Shared Documents and changes single text field value of the list item

spo file add --webUrl https://contoso.sharepoint.com/sites/project-x --folder 'Shared Documents' --path 'C:\MS365.jpg' --Title "New Title"

Adds file MS365.jpg to site https://contoso.sharepoint.com/sites/project-x in folder Shared Documents and changes person/group field and DateTime field values

spo file add --webUrl https://contoso.sharepoint.com/sites/project-x --folder 'Shared Documents' --path 'C:\MS365.jpg' --Editor "[{'Key':'i:0#.f|membership|john.smith@contoso.com'}]" --Modified '6/23/2018 10:15 PM'

Adds file MS365.jpg to site https://contoso.sharepoint.com/sites/project-x in folder Shared Documents and changes hyperlink or picture field

spo file add --webUrl https://contoso.sharepoint.com/sites/project-x --folder 'Shared Documents' --path 'C:\MS365.jpg' --URL 'https://contoso.com, Contoso'

Adds file MS365.jpg to site https://contoso.sharepoint.com/sites/project-x in folder Shared Documents and changes taxonomy field

spo file add --webUrl https://contoso.sharepoint.com/sites/project-x --folder 'Shared Documents' --path 'C:\MS365.jpg' --Topic "HR services|c17baaeb-67cd-4378-9389-9d97a945c701"

Adds file MS365.jpg to site https://contoso.sharepoint.com/sites/project-x in folder Shared Documents and changes taxonomy multi-value field

spo file add --webUrl https://contoso.sharepoint.com/sites/project-x --folder 'Shared Documents' --path 'C:\MS365.jpg' --Topic "HR services|c17baaeb-67cd-4378-9389-9d97a945c701;Inclusion & Diversity|66a67671-ed89-44a7-9be4-e80c06b41f35"

Adds file MS365.jpg to site https://contoso.sharepoint.com/sites/project-x in folder Shared Documents and changes choice field and multi-choice field

spo file add --webUrl https://contoso.sharepoint.com/sites/project-x --folder 'Shared Documents' --path 'C:\MS365.jpg' --ChoiceField1 'Option3' --MultiChoiceField1 'Option2;#Option3'

Adds file MS365.jpg to site https://contoso.sharepoint.com/sites/project-x in folder Shared Documents and changes person/group field that allows multi-user selection

spo file add --webUrl https://contoso.sharepoint.com/sites/project-x --folder 'Shared Documents' --path 'C:\MS365.jpg' --AllowedUsers "[{'Key':'i:0#.f|membership|john.smith@contoso.com'},{'Key':'i:0#.f|membership|velin.georgiev@contoso.com'}]"

Adds file MS365.jpg to site https://contoso.sharepoint.com/sites/project-x in folder Shared Documents and changes yes/no field

spo file add --webUrl https://contoso.sharepoint.com/sites/project-x --folder 'Shared Documents' --path 'C:\MS365.jpg' --HasCar true

Adds file MS365.jpg to site https://contoso.sharepoint.com/sites/project-x in folder Shared Documents and changes number field and currency field

spo file add --webUrl https://contoso.sharepoint.com/sites/project-x --folder 'Shared Documents' --path 'C:\MS365.jpg' --NumberField 100 --CurrencyField 20

Adds file MS365.jpg to site https://contoso.sharepoint.com/sites/project-x in folder Shared Documents and changes lookup field and multi-lookup field

spo file add --webUrl https://contoso.sharepoint.com/sites/project-x --folder 'Shared Documents' --path 'C:\MS365.jpg' --LookupField 1 --MultiLookupField "2;#;#3;#;#4;#"

More information