view to upload a Buffer to Box. But I have been receiving the following error :
{ message: 'Bad request',type: 'error',details: [ { message: 'Unsupported document type.' } ] }
my code is the following :
var boxViewLib= require('box-view');
var boxView =boxViewLib.createClient(process.env.BOX_KEY);
var boxOptions = {
params:{ name:'red.jpg'}
,retry : true
}
// the params.Body is a Buffer
boxView.documents.uploadFile(params.Body, boxOptions, function(err, boxData) {
console.log('Upload to Box View');
console.log('Err '+ err);
console.log( boxData);
});
response is :
Upload to Box View
Err Error: Bad request
{ message: 'Bad request',
type: 'error',
details: [ { message: 'Unsupported document type.' } ] }
Are you actually trying to upload a JPEG image? The View API currently only supports documents and text files (see the full list here: https://developers.box.com/view/#filetypes).
Otherwise, your code looks fine.