Skip to content

File

Download and upload file via kintone Rest API.

Constructor

Parameter

Name Type Required Description
connection Connection yes The connection module of this SDK.

Sample code

Init app sample

Javascript


  var kintoneFile = new kintoneJSSDK.File(connection);

Nodejs


  const kintone = require('@kintone/kintone-js-sdk');
  let kintoneFile = new kintone.File(connection);

Methods

upload(fileName, fileBlob)

Upload file into kintone

Parameter

Name Type Required Description
fileName String yes The name of file
fileBlob Blob yes This param only use for Javascript
The content of file
fileContent Stream yes This param only use for Nodejs
The content of file

Return

Promise

Sample code

Upload file sample

Javascript


  var fileBlob = 'your_file_blob';
  var fileName = 'your_file_name';
  kintoneFile.upload(fileName, fileBlob).then((rsp) => {
    console.log(rsp);
  }).catch((err) => {
    // This SDK return err with KintoneAPIExeption
    console.log(err.get());
  });

Nodejs


  const fileContent = fs.createReadStream('./cd.png');
  const fileName = path.basename('./cd.png');
  kintoneFile.upload(fileName, fileContent).then((rsp) => {
    console.log(rsp);
  }).catch((err) => {
    // This SDK return err with KintoneAPIExeption
    console.log(err.get());
  });

upload(filePath)

Upload file into kintone using nodejs

Parameter

Name Type Required Description
filePath String yes The path of file

Return

Promise

Sample code

Upload file sample

Nodejs


  const filePath = './cd.png';

  kintoneFile.upload(filePath).then((rsp) => {
    console.log(rsp);
  }).catch((err) => {
    // This SDK return err with KintoneAPIExeption
    console.log(err.get());
  });

download(fileKey, outPutFilePath)

Download file from kintone

Parameter

Name Type Required Description
fileKey String yes The file key of the uploaded file on kintone.
outPutFilePath String yes This param only use for Nodejs
The full path of output file on your environment

Return

Promise

Sample code

Get apps sample

Javascript


  var fileKey = 'your_file_Key';
  kintoneFile.download(fileKey).then(rsp => {
    console.log(rsp);
  }).catch((err) => {
    // This SDK return err with KintoneAPIExeption
    console.log(err.get());
  });

Nodejs


  const fileKey = 'your_file_Key';
  const outPutFilePath = 'your_output_directory';
  kintoneFile.download(fileKey, outPutFilePath).catch((err) => {
    // This SDK return err with KintoneAPIExeption
    console.log(err.get());
  });

Reference