2017-08-03 93 views
0

嘿,我使用Box API和成功上传我的文件,但它们存储在应用程序存储文件夹中。如果你想去管理控制台,然后点击文件夹图标,你可以看到管理文件夹,然后看到创建的应用程序的文件夹。如何更改每次上传到管理员文件夹的路径,如果我重新登录到box.com,我会在家庭文件夹中看到所有文件,而不是每次都进入管理控制台?Box API将文件上传到管理员帐户而不是APP

回答

2

这应该工作。

var client = sdk.getAppAuthClient('enterprise', ENTERPRISE_ID); 

    //filter_term == admin to share the folder with 
    client.enterprise.getUsers({filter_term: '[email protected]'}, 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); 
      } 
     }); 
    }); 
}); 
}); 
+0

嘿,谢谢你的赞扬。我会测试明天并报告。 – t33n

+0

你是我的英雄狗!据我所看到的箱子支持没有从上传进度的跟踪。就像googledrive一样,你可以用req.connection.bytesWritten作为例子。或者有没有你知道的方法? Btw你是否也使用onedrive API? – t33n

+0

我不知道这样做的方法。抱歉! – kendomen

相关问题