File
Download and upload file via kintone Rest API.
Constructor
Parameter
Name | Type | Required | Description |
---|---|---|---|
params | Object | yes | The parameters that include connection property |
params.connection | Connection | (optional) | The connection module of this SDK. If initializing in browser environment on kintone, this parameter can be ommited to use session authentication. |
Sample code
Init app sample
Javascript
// with connection var kintoneFile = new kintoneJSSDK.File({connection: connection}); // without connection, module will use session authentication of kintone var kintoneFile = new kintoneJSSDK.File();
Nodejs
const kintone = require('@kintone/kintone-js-sdk'); let kintoneFile = new kintone.File({connection: connection});
Methods
upload(params)
Upload file into kintone
Parameter
Name | Type | Required | Description |
---|---|---|---|
params | Object | yes | The parameters that include fileName, fileBlob, fileContent properties |
params.fileName | String | yes | The name of file |
params.fileBlob | Blob | yes | This param only use for Javascript The content of file |
params.fileContent | Stream | yes | This param only use for Nodejs The content of file |
Return
Promise
Sample code
Upload file sample
Javascript
var params = { fileBlob: 'your_file_blob', fileName: 'your_file_name' }; kintoneFile.upload(params).then((rsp) => { console.log(rsp); }).catch((err) => { // This SDK return err with KintoneAPIExeption console.log(err.get()); });
Nodejs
const params = { fileContent: fs.createReadStream('./cd.png'), fileName: path.basename('./cd.png') }; kintoneFile.upload(params).then((rsp) => { console.log(rsp); }).catch((err) => { // This SDK return err with KintoneAPIExeption console.log(err.get()); });
upload(params)
Upload file into kintone using nodejs
Parameter
Name | Type | Required | Description |
---|---|---|---|
params | Object | yes | The parameters that include filePath property |
params.filePath | String | yes | The path of file |
Return
Promise
Sample code
Upload file sample
Nodejs
const params = { filePath: './cd.png' }; kintoneFile.upload(params).then((rsp) => { console.log(rsp); }).catch((err) => { // This SDK return err with KintoneAPIExeption console.log(err.get()); });
download(params)
Download file from kintone
Parameter
Name | Type | Required | Description |
---|---|---|---|
params | Object | yes | The parameters that include fileKey, outPutFilePath properties |
params.fileKey | String | yes | The file key of the uploaded file on kintone. |
params.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 params = { fileKey: 'your_file_Key', outPutFilePath: 'your_output_directory' }; kintoneFile.download(params).then(rsp => { //file blob console.log(rsp); }).catch((err) => { // This SDK return err with KintoneAPIExeption console.log(err.get()); });
Nodejs
const params = { fileKey: 'your_file_Key', outPutFilePath: 'your_output_directory' }; kintoneFile.download(params).catch((err) => { // This SDK return err with KintoneAPIExeption console.log(err.get()); });
Reference
- Upload File
on developer network
- Download File
on developer network