Forum Discussion
Jon Ivar Kleveland
Mar 17, 2017Copper Contributor
Copy documents between libraries with js pnp
Hi, I'm looking for some samples using PnP js to copy documents between libraries in SPO. (I've tries Binging etc...) Any?
- Mar 19, 2017
Hi there,
It can be done with `copyTo` method. With pnp-core-js:$pnp.sp.web .getFileByServerRelativeUrl('/sites/dev01/DocLib01/tttt/Development and Deployment Guidelines.pdf') .copyTo('/sites/dev01/DocLib03/Development and Deployment Guidelines.pdf', true) .then(function(res) { console.log(res); });
Which constructs POST request to the following REST endpoint:
/_api/web /getfilebyserverrelativeurl('[server relative url of the file to copy') /copyto(
strnewurl='[server reletive url where to copy, including file name]',
boverwrite=true)--
Cheers,
Andrew
Vandana Chadha
Feb 07, 2018Copper Contributor
Hello,
How can we maintain versioning in the target library while copying the files from Source to target, if the target library has versioning enable. Please suggest!
Thanks!!
Nigel_Price9911
Feb 08, 2018Iron Contributor
bump - any progress on this ?