将API上载文件箱到管理员帐户而不是APP [英] Box API upload files to admin account instead of APP
本文介绍了将API上载文件箱到管理员帐户而不是APP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嘿,我使用Box API并成功上传了文件,但它们存储在应用程序存储文件夹中。如果您要转到管理控制台,然后单击文件夹图标,则可以看到admin文件夹,然后看到创建的应用程序的文件夹。如何更改每次上载将进入admin文件夹的路径,如果我重新登录box.com,我会看到我的主文件夹中的所有文件,而不是每次都进入admin-console?
Hey I use the Box API and I successfull to upload my files but they are stored at the app storage folder. If you would go to the admin-console and then click the folder Icon you can see the admin folder and then the folder of the created app. How can I change the path that every upload will go to the admin folder that if I relog to box.com I would see all my files in the home folder instead of going to the admin-console every time?
推荐答案
这应该有效。
var client = sdk.getAppAuthClient('enterprise', ENTERPRISE_ID);
//filter_term == admin to share the folder with
client.enterprise.getUsers({filter_term: 'ken.domen@nike.com'}, function(err, users) {
var userId = users.entries[0].id;
client.folders.create('0', 'New Folder', function(err, newFolder) {
client.collaborations.createWithUserID(userId, newFolder.id, client.collaborationRoles.VIEWER, function(err, collaboration) {
console.log(err);
var fileData = fs.createReadStream('/users/kdomen/Downloads/test.txt')
client.files.uploadFile(newFolder.id, 'test.txt', fileData, function(err, file) {
if (err){
console.log('err: ' + err);
}
else{
console.log('file uploaded: ' + file);
}
});
});
});
});
这篇关于将API上载文件箱到管理员帐户而不是APP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文