GithubHelp home page GithubHelp logo

alimughalx / copysharepointfileinchunks Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 10 KB

Copy large files from Source SharePoint library to Destination SharePoint library into small chunks.

License: MIT License

PowerShell 100.00%
sharepoint powershell-script chunking file-upload sharepoint-online sharepoint2013 sharepoint-2016 sharepoint2019 powershell

copysharepointfileinchunks's Introduction

CopySharePointFileInChunks

Copy large files from Source SharePoint library to Destination SharePoint library into small chunks. In our Case we were facing an issue while copying a file with PS which can cause error on file size greater than 100MB.

SharePoint has a maximum upload size that varies depending upon your version. The migration mode (Insane mode, Normal mode) you use can also affect the total file size you can migrate in SharePoint.So in that case, this script will chunk files in 10MB smaller portions, block size can be increased up to 99MB

How to Use? Simple and easy to use. Change the following ones to get it work:

$DestnationSiteUrl = "https://your-domain.sharepoint.com/sites/xyz" #URL to Configure, in this case Destination is SP Online site URL, it can be set on On-Prem too.
$DestinationRelativeURL = "/sites/xyz/TestLibrary" #Server Relative URL here with library Name and in case of specific folder name
$DestinationUserName = "[email protected]" #User to be used as SP Online site
$DestinationPassword =  To make things secure getting input Password -AsSecureString in PS

$DestnationSiteUrl = "http://intranet/sites/xyz" #URL to Configure, in this case Destination is SP Online site URL, it can be set on On-Prem too.
$DestinationRelativeURL = "/sites/xyz/TestLibrary/myfile.pptx" #Server Relative URL here with library Name and in case of specific folder name
$DestinationUserName = "domain\xyz" #User to be used as SP Online site
$SourcePassword =  To make things secure getting input Password -AsSecureString in PS

$FileNameWithExt =  "xyz.pptx" file name with extension. It can be any type of file which sharepoint supports.

In Order to re-use context initialize that out side the function and pass context as parameter to function

Function Info:

    UploadFileInSlice ($DestinationCtx, $SourceCtx, $SourceFileUrl, $DestinationFolderUrl, $fileName, $fileChunkSizeInMB)

Paramters Info:

    $DestinationCtx =  Destination SharePoint Client Context of SP Online destination e.g. "https://your-domain.sharepoint.com/sites/xyz".
    $SourceCtx =  Source SharePoint Client Context of on-prem source e.g. "http://intranet/sites/xyz".
    $SourceFileUrl = Server relative URL of file to be copied with library Name and file name and extension e.g "/sites/xyz/TestLibrary/myfile.pptx".
    $DestinationFolderUrl =  Server relative URL of destination folder where file needs to be copied.
    $fileName =  File Name with extension in order to change the file name on destination 
    $fileChunkSizeInMB = Passing an integer between 1-99 as MB

How if works? Function compares file size and chunk size. If file size is less than chunk size then the script will copy the file directly with [Microsoft.SharePoint.Client.File]::SaveBinaryDirect function.

In case of file size is greater than chunk size , script will read bytes and uploads the file into small chunks untill it reaches to the end block of bytes. And thats it!

Find more about the upload size limitations https://support-desktop.sharegate.com/hc/en-us/articles/115000644148.

When copying a file that exceeds one of these limits, ShareGate Desktop signals an error indicating that the file is too large and that the element cannot be created in your destination.

Maximum upload size for a document in a library
  SharePoint on premises prior to SharePoint 2016: 2 gigabytes
  SharePoint 2016: 10 gigabytes
  SharePoint 2019: 15 gigabytes
  Office 365: 100 gigabytes in Normal mode, 15 gigabytes in Insane mode.

Maximum upload size for a list item attachment
  SharePoint on premises: 50 megabytes
  Office 365: 250 megabytes

copysharepointfileinchunks's People

Contributors

alimughalx avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.