0
與此相關的帖子Box API Node.js cant upload file 404 Error
我用awnser代碼從下面要權威性我的應用程序 它與顯示我的用戶名,使身份驗證全成。 如果我看看我的任務管理器,我可以看到有傳出流量/正常運行時間 速度,因此文件將在用戶檢查後上載到函數中。而且我也進入了其他區域,所以成功上傳。但是,如果我看着我的箱子網站區域,我不能看到該文件。當我嘗試再次運行該腳本時,我得到了該文件已存在的錯誤409。任何想法,爲什麼我不能在box.com上看到該文件?我手動添加響應和正文進行調試,但未找到它們。此外,我啓用所有範圍在box.com的開發者區域盒API不容看到我上傳的文件
成功登錄到box.com - 您的APP名稱:xxxxxxx! 文件上傳:[對象的對象] 別人身上:未定義 別的響應:未定義
這是我的代碼
// BOX
var BoxSDK = require('box-node-sdk');
var config = require('config')
var sdk = new BoxSDK({
clientID: config.get('boxAppSettings.clientID'),
clientSecret: config.get('boxAppSettings.clientSecret'),
appAuth: {
keyID: config.get('boxAppSettings.appAuth.publicKeyID'),
privateKey: config.get('boxAppSettings.appAuth.privateKey'),
passphrase: config.get('boxAppSettings.appAuth.passphrase'),
expirationTime: 60,
verifyTimestamp: false
}
});
var client = sdk.getAppAuthClient('enterprise', "2xxxxxxxx5");
//Get some of that sweet, sweet data!
client.users.get(client.CURRENT_USER_ID, null, function(err, currentUser) {
if(err) throw err;
console.log('Hello, ' + currentUser.name + '!');
});
var fileData = fs.createReadStream('C:\\Exports\\box2.zip');
client.files.uploadFile('0', 'box2.zip', fileData, function(err, file, body, response) {
if (err){
console.log('err while upload file: ' + err)
console.log('if body: ' + body);
console.log('if response: ' + response);
}
else{
console.log('file uploaded: ' + file);
console.log('else body: ' + body);
console.log('else response: ' + response);
}
});
omg是的你是對的。這是非常神祕的:D有沒有一種方法可以隨時通過管理員上傳,當我登錄到我的帳戶時,我可以直接看到這些文件? – t33n
您可以將管理員作爲協作者添加到在服務帳戶中創建的文件夾中。 – kendomen
謝謝你的幫助兄弟:)但是這個服務帳戶區域在哪裏.-我已經在普通的box.com區域和開發者區域進行了搜索,但是有太多的選項不確定你的意思。你可以給我一個URL或屏幕,我明白你的意思。會很棒 – t33n