I have a Task to move data of Document Library from on Site to sub site, below is the situation, Using office 365 Need to migrate a library and its folder to a sub site where folders would be treated as libraries in that sub site The size of the library is 3.29 GB. I have to write a custom code for this. The various details of the documents etc must be restored like the modification date, version history etc.
You need to save the Document Library as template including its content:
Reference: SharePoint Online - Migrate document library