Skip to main content

spo file add

Uploads file to the specified folder

Usage​

m365 spo file add [options]

Options​

-u, --webUrl <webUrl>

The URL of the site where the file should be uploaded to

-f, --folder <folder>

The server- or site-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

-h, --help [help]

Output usage information. Optionally, specify which section of command's help you want to see. Allowed values are options, examples, remarks, response, full. Default is full.

--query [query]

JMESPath query string. See http://jmespath.org/ for more information and examples.

-o, --output [output]

Output type. json, text, csv, md. Default json.

--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

m365 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

m365 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

m365 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

m365 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

m365 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)

m365 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

m365 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

m365 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

m365 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

m365 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

m365 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

m365 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

m365 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

m365 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

m365 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

m365 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

m365 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​