这应该行得通。
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);
}
});
});
});
});