ClimberCloud: Upload File
Uploads a ClimberCloud’s ‘list with file’ to a specified content ID in ClimberCloud.
Configs for this Auto Step
- conf_TenantId
- C1: Tenant ID *#{EL}
- conf_ApiKey
- C2: Api Key *#{EL}
- conf_PdfFile
- C3: PDF file for upload *
- conf_IndexFile
- C4: Index file for upload *
- conf_ContentsId
- C5: Contents id for upload *#{EL}
- conf_doc_id
- C6: Climber document id(doc_id) (update)
- conf_log
- X: Access Log (update)
Script (click to open)
main();
function main(){
//// == Config Retrieving / 工程コンフィグの参照 ==
const tenantId = configs.get( "conf_TenantId" ) + "";
const apiKey = configs.get( "conf_ApiKey" ) + "";
const contentsId = configs.get( "conf_ContentsId" ) + "";
const dataId_pdfFile = configs.get( "conf_PdfFile" );
const dataId_indexFile = configs.get( "conf_IndexFile" );
const dataId_doc_id = configs.get( "conf_doc_id" );
const dataId_log = configs.get( "conf_log" );
//// == 演算 / Calculating ==
if ( tenantId == "" ) {
throw `Tenant ID none.`;
}
if ( apiKey == "" ) {
throw `API key none.`;
}
if ( contentsId == "" ) {
throw `Contents ID none.`;
}
let accessLog = "";
//ファイルBase64変換
//ファイルの上限サイズは10MB
const files = engine.findDataByNumber( dataId_pdfFile );
let base64Text = "";
if (( !files ) || ( files.length != 1 )) {
throw `PDF File Num invalid.`;
}
const file = files.get(0);
if ( file.getLength() > 10485760 ) {
throw `PDF File size over.`;
}
fileRepository.readFile(file, 10485760, function(bytes) {
base64Text += base64.encodeToString(bytes);
});
//engine.log("base64Text:" + base64Text);
const files2 = engine.findDataByNumber( dataId_indexFile );
let base64Text2 = "";
if (( !files2 ) || ( files2.length != 1 )) {
throw `Index File Num invalid.`;
}
const file2 = files2.get(0);
if ( file2.getLength() > 10485760 ) {
throw `Index File size over.`;
}
fileRepository.readFile(file2, 10485760, function(bytes) {
base64Text2 += base64.encodeToString(bytes);
});
//engine.log("base64Text2:" + base64Text2);
//JSON生成
let requestObj = {};
requestObj.data_file_name = file.getName();
requestObj.index_file_name = file2.getName();
// requestObj.scan_file_name = ;
requestObj.ext_doc_id = processInstance.getProcessInstanceId();
requestObj.contents_id = contentsId;
// requestObj.shorting_folder_id = ;
requestObj.compress_type = "0";
requestObj.data_type = "1";
requestObj.paper_type = "0";
requestObj.host_type = "0";
requestObj.data_file = base64Text;
requestObj.index_file = base64Text2;
// requestObj.scan_file = ;
//engine.log("json:" + JSON.stringify(requestObj));
//APIコール
const uri = "https://api.climber-cloud.jp/api/ArchiveRequest";
let response = httpClient.begin()
.header( "X-Tenant", tenantId )
.header( "X-ApiKey", apiKey )
.body( JSON.stringify(requestObj), "application/json" )
.post( uri );
accessLog += "---POST request--- " + response.getStatusCode() + "\n";
accessLog += response.getResponseAsString() + "\n";
engine.log("res:" + response.getResponseAsString());
const status = response.getStatusCode();
if( status >= 300 ){
engine.log(accessLog);
throw `Failed in POST request. status: ${status}`;
}
//APIコール結果確認
const jsonObj = JSON.parse( response.getResponseAsString() );
const isSuccess = jsonObj.isSuccess + "";
engine.log("isSuccess:" + isSuccess);
if ( isSuccess !== "0") {
const message = jsonObj.message + "";
engine.log("message:" + message);
throw `Failed in request. isSuccess: ${isSuccess} message: ${message}`;
}
//// == ワークフローデータへの代入 / Data Updating ==
const doc_id = jsonObj.doc_id + "";
engine.log("doc_id:" + doc_id);
if ( dataId_doc_id !== "" ) {
engine.setDataByNumber( dataId_doc_id, doc_id );
}
if ( dataId_log !== "" ) {
engine.setDataByNumber( dataId_log, accessLog );
}
}
Download
- ClimberCloud-File-Upload.xml
- 2023-01-20 (C) Questetra, Inc. (MIT License)
(Installing Addon Auto-Steps are available only on the Professional edition.)
Notes
- ClimberCloud is a service provided by NTT Data Business Brains, Inc. and is JIIMA certified (the service is compliant with the Electric Ledger Law and Invoice System).
- It is intended to be used in combination with [ClimberCloud Index File: Create].
- For details on how to obtain a ClimberCloud API key and index file specifications, please refer to the ClimberCloud service (Support > Terms of Use/Specifications > WEBAPI Specifications). For a ClimberCloud trial, please apply from the ClimberCloud website.
- In the file upload API call, the Questetra process ID is specified as the “External System Management No (ext_doc_id)”.
Capture
