Is there a client side javascript library for OneD

2019-08-09 01:52发布

问题:

I'm looking for a file picker control like the one offered in the OneDrive (live connect) javascript library, but which instead is for "OneDrive for Business". In other words, I want to be able to prompt the user to select a "OneDrive for Business" document, which I can then do something with using (presumably) the REST API.

I'm a little confused as to the API support for OneDrive for Business. My understanding is that OneDrive for Business is based on Sharepoint 2013 and I can use the Sharepoint 2013 REST and CSOM API's to access my files hosted in Office 365.

I couldn't see any support for such a feature in the CSOM javascript documentation I looked at. But I know little to nothing about Sharepoint so perhaps there's something out there already?

There also appears to be a new Office 365 REST API with javascript libraries under development. I'm guessing this is the most likely candidate to give me what I want. Of course, I can write my own control using the REST API's if I have to.

回答1:

Your understanding that OneDrive for Business is based on SharePoint 2013 is mostly correct. In reality, OneDrive for Business IS SharePoint 2013--it's just a new name for a certain part of SharePoint 2013.

I have worked extensively on OneDrive for Business and SharePoint as a whole, and as far as I know, no such control exists. All of the API that I'm aware of (except perhaps some APIs in the Social part of SharePoint 2013) is functionality-focused, and does not provide controls. This is by design, because SharePoint has a rich ecosystem of customization and extension that wants functionality to be present in order to build custom UI on top of, and in most cases a standardized javascript control would be a glaring exception, from a UI design perspective.

I would encourage you to implement the control using the SharePoint 2013 REST API. Specifically, the calls regarding file operations are here: http://msdn.microsoft.com/en-us/library/office/dn450841(v=office.15).aspx.

I haven't used the new Office 365 REST API yet, but looking at the status of it, the "My Files" portion hasn't yet been released for JavaScript (source: http://blogs.office.com/2014/05/12/net-and-javascript-libraries-for-office-365-apis/), and since it may or may not have what you need I would recommend sticking with the existing SharePoint 2013 REST API that will definitely be able to do what you want.

I wouldn't be surprised if someone outside of Microsoft had already written one, but I couldn't find anything posted online, so either it hasn't been done or hasn't been made easily available online.