kintone Plugin Proxy Upload

kintone Plugin Proxy Upload kintone.plugin.app.proxy.upload()

Upload a file to outside of kintone from a plugin.
If your external REST API requires sensitive information such as secret keys, use the Set Config for proxy() API and Get Config for proxy() API on save and get these data for the external REST API.

Function

kintone.plugin.app.proxy.upload(pluginId, url, method, headers, data, callback, error)

Parameters

PARAMETER TYPE REQUIRED DESCRIPTION
pluginId Object Yes The Plugin ID of the Plugin that will run the API.
url String Yes The request URL.
method String Yes The HTTP method. Specify one of the following: POST / PUT.
headers Object Yes Specify the request header as an object. To ignore this parameter, input {}. Sample: {'Content-Type': 'application/json'}
data Object Yes The data that will be sent in the request.
{ 'format': format to be uploaded to the external service. 'value': data to be uploaded }
For format, you can only specify the string "RAW".
For value, specify the value of the Blob type (including File type). The maximum size is 200MB.
callback Function Optional The callback function that will run when the request to the external service has finished. It will receive the response body (string), the status code (number) and the response header (object) as parameters from the external service.
If this parameter is ignored, a kintone.Promise object will be returned that can be fulfilled with an array containing a Response body (string), Status code (number) and Response header (object).
error Function Optional The callback function that will run when the API request to the external service fails. It will receive the response body (string) as the parameter from the external service.
If this parameter is ignored, a kintone.Promise object will be returned that can be rejected with the response body (string) from this API.

Response

A kintone.Promise object will be returned if the callback parameter is ignored. Otherwise, there will be no response.

Available Pages

The following desktop pages:

  • Record List
  • Record Details
  • Record Create
  • Record Edit
  • Record Print
  • Graph
  • File Import
  • File Export

 

The following smartphone pages:

  • Record List
  • Record Details
  • Record Create
  • Record Edit

Sample Request

kintone.plugin.app.proxy('mjjfipoklghomcgafnajfibfgllhpocm', 'https://api.example.com', 'POST', {}, {'format': 'RAW', 'value': 
}, function(body, status, headers) {
    console.log(status, JSON.parse(body), headers);
}, function(error) {
    console.log(error);  //Display the response body (string) from the proxy API
};

Sample Request using Promises

kintone.plugin.app.proxy('mjjfipoklghomcgafnajfibfgllhpocm', 'https://api.example.com', 'POST', {}, {'format': 'RAW', 'value': 
}).then(function(args) {
    /*  args[0] -> body(String)
     *  args[1] -> status(Number)
     *  args[2] -> headers(Object)
     */
    console.log(args[1], JSON.parse(args[0]), args[2]);
}, function(error) {
    console.log(error);  //Display the response body (string) from the proxy API
});

Limitations

  • Compatible browsers are: Internet Explorer 11, Mozilla Firefox(latest version), Google Chrome(latest version), Safari(latest version), iOS Safari (latest version), and Android Chrome(latest version).
Was this article helpful?
0 out of 0 found this helpful
Comments
Please sign in to leave a comment.