File 使用Onedrive(skydire)API获取下载和共享链接,无需下载
请有人帮助我演示如何修改此脚本,以便使用Onedrive API获取大小和mimetype文件的下载和共享链接,而不下载此函数中的文件:File 使用Onedrive(skydire)API获取下载和共享链接,无需下载,file,api,onedrive,picker,File,Api,Onedrive,Picker,请有人帮助我演示如何修改此脚本,以便使用Onedrive API获取大小和mimetype文件的下载和共享链接,而不下载此函数中的文件: WL.init({ client_id: clientId, redirect_uri: redirectUri }); WL.login({ "scope": "wl.skydrive wl.signin" }).then( function(response) { openFromSkyDrive(); },
WL.init({ client_id: clientId, redirect_uri: redirectUri });
WL.login({ "scope": "wl.skydrive wl.signin" }).then(
function(response) {
openFromSkyDrive();
},
function(response) {
log("Failed to authenticate.");
}
);
function openFromSkyDrive() {
WL.fileDialog({
mode: 'open',
select: 'single'
}).then(
function(response) {
log("The following file is being downloaded:");
log("");
var files = response.data.files;
for (var i = 0; i < files.length; i++) {
var file = files[i];
log(file.name);
WL.download({ "path": file.id + "/content" });
}
},
function(errorResponse) {
log("WL.fileDialog errorResponse = " + JSON.stringify(errorResponse));
}
);
}
function log(message) {
var child = document.createTextNode(message);
var parent = document.getElementById('JsOutputDiv') || document.body;
parent.appendChild(child);
parent.appendChild(document.createElement("br"));
}
演示链接:
感谢您的帮助。我看到从选择器返回的文件变量具有以下属性: id、描述、名称、类型、链接、上传位置、来源、照片 通过此版本的openFromSkyDrive方法:
function openFromSkyDrive() {
WL.fileDialog({
mode: 'open',
select: 'single'
}).then(
function(response) {
log("The following file is being downloaded:");
log("");
var files = response.data.files;
for (var i = 0; i < files.length; i++) {
var file = files[i];
log(file.name);
/* show all the the properties of 'file' variable */
for( var p in file){
log(p);
}
/* get the type, which really isn't a full mimetype */
log(file.type);
/* get the share link */
log(file.link);
/* do not download the file */
// WL.download({ "path": file.id + "/content" });
}
},
function(errorResponse) {
log("WL.fileDialog errorResponse = " + JSON.stringify(errorResponse));
}
);
}