Quantcast
Viewing all articles
Browse latest Browse all 6517

New Post: Move/copy item from/to document library

I know this is old thread, but I needed the Copy Functionality without the Link as well, so here's the code (since there's no current examples). Note: You'll have to add your error-checking where appropriate. This is just to show others how to use.

You need to use the GetItem block first against your document to retrieve the document's Byte Stream; which then allows you to use the CopyIntoItems function which creates a new document at the destination. Note: you also get all the file Params from "GetItem" if that interest you. I just wanted the Byte Stream.
    var myStream = "";
    jQuery().SPServices({
        operation: "GetItem",
        async: false,
        Url: mOrgPath,
        completefunc: function(xData, Status) {
            myStream = jQuery(xData.responseXML).find("Stream").text(); //MSDN: base-64 representation of the retrieved document's binary data.
            } // end completefunc
    }); // end getItem
Now that we have the Byte stream, we can proceed with CopyIntoItems, which is very similar to CopyIntoItemsLocal with the exception that it allows multiple destinations, and requires the Byte steam.
    jQuery().SPServices({
        operation: "CopyIntoItems",
        async: false,
        SourceUrl: "http://myserver/mydoclib/myfile.pdf",
        DestinationUrls: ["http://myserver/mydestinationdoclib/myfile.pdf"],
        Stream: myStream, //whatever variable you used to store the base64 encoded binary data from the GetItem call
        completefunc: function(xData, Status) {
            alert("Status=" + Status + "\n" + xData.responseText);
            } // end completefunc
    }); // end CopyIntoItems
That's it I think, thanks for the awesome library!

Viewing all articles
Browse latest Browse all 6517

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>