File download does not work using API
回答済みI used this code
↓
↓
-----------------------------------------------------------------------------
const BoxSDK = require('./node_modules/box-node-sdk');
const sdkConfig = require('./config.json');
const sdk = BoxSDK.getPreconfiguredInstance(sdkConfig);
const client = sdk.getAppAuthClient('enterprise');
const fs = require('fs');
client.files.getReadStream('fileID', null, function(error, stream) {
if (error) {
// handle error
}
console.log(stream);
// write the file to disk
constoutput=fs.createWriteStream('sample.txt');
stream.pipe(output);
});
------------------------------------------------------------------
but an error occurs
↓
↓
undefined
/home/mg0x42y7214f7c/BOX-app/HTML/node_modules/bluebird/js/release/async.js:49
fn = function () { throw arg; };
^
TypeError: Cannot read property 'pipe' of undefined
I cant download file and i want help.
-
Hi
I think you will get this error when the fileID you are trying to read either doesn't exist or the user executing the call does not have access to it.
If you add some error handling logic you will probably see a 404 status code being returned.
Hope this helps
Peter Christensen, Platform Solutions Engineer, Box
サインインしてコメントを残してください。
コメント
1件のコメント