Skip to content

Files and Folders

Takashi Shinohara edited this page Aug 31, 2021 · 1 revision

Upload a file

There are two ways to upload a file using the cmdlets Add-KshFile and Save-KshFile.

The difference is:

  • The Add-KshFile cmdlet uses FileCreationInformation class. Maximum file size that can be uploaded is 2 MB.
  • The Save-KshFile cmdlet uses StartUpload, ContinueUpload, and FinishUpload method on the File class. No file size limits.

For more details, see docs.

$folder = Get-KshFolder -FolderUrl '/sites/japan/hr/Shared%20Documents'
$fstream = [System.IO.File]::OpenRead('./README.txt')
Save-KshFile -Folder $folder -Content $fstream -FileName 'README.txt'

Download a file

Use the Open-KshFile cmdlet in order to download a file.

$file = Get-KshFile -FileUrl '/sites/japan/hr/Shared%20Documents/README.txt'
$istream = Open-KshFile -Identity $file
$fstream = [System.IO.File]::OpenWrite('./README.txt')
$istream.CopyTo($fstream)
$istream.Close()
$fstream.Close()
Clone this wiki locally