I'm working on a web project which uses the OneDrive API for file management purposes. I wanted to create *.docx | *.pptx | *.xlsx files but unfortunately, none of the OneDrive APIs support creating empty/new files. What I tried was to upload an empty/new file from my server to OneDrive. While the upload works fine, the file does not open in Office Online nor in local Office.
From this blog, I was able to generate a Word file and upload it.
function createNewDoc(name) {
var htmlString = "<html><body></body></html>";
var byteNumbers = new Uint8Array(htmlString.length);
for (var i = 0; i < htmlString.length; i++) {
byteNumbers[i] = htmlString.charCodeAt(i);
}
var blob = new Blob([byteNumbers], {type: "text/html"});
socialAPI.uploadFile('windows', blob, 'name', 'folder.87ash7ashb7a2').then(function (resp) {
console.log("response for uploading file", resp);
})
}
This file worked for Word. However, the method doesn't work for Excel and Powerpoint.
So ultimately, I was not able to do anything using the OneDrive API. I started looking at Office 365 API if there's anything which allows creation of above mentioned files but I couldn't find anything like that. (P.S: I'm looking at REST APIs)
Another thing I noticed is Box is able to do the same and open it in a window, but the url is in the format https://app.box.com/services/box_for_office_online. Does Box have some special collaboration with Microsoft to provide such a service?