2024-04-16 This item downloads a file and adds to file-type data. The GET request to the URL is thrown and the response is saved as a file. この工程は、ファイルをダウンロードし、ファイル型データに追加します。指定したURLへGETリクエストが投げられ、そのレスポンスがファイルとして保存されます。 (C) Questetra, Inc. (MIT License) 3 2 https://support.questetra.com/bpmn-icons/any-website-file-download/ https://support.questetra.com/ja/bpmn-icons/any-website-file-download/ { let auth; if (authType !== "") { if (authType === "Box") { auth = httpClient.createAuthSettingOAuth2( 'Box', 'https://account.box.com/api/oauth2/authorize', 'https://api.box.com/oauth2/token', 'root_readwrite', 'consumer_key', 'consumer_secret', 'access_token' ); } if (authType === "Basic") { auth = httpClient.createAuthSettingBasic('Basic Auth', 'user', 'pass'); } configs.putObject('conf_OAuth2', auth); } configs.put('conf_DataIdA', url); const fileDef = engine.createDataDefinition('ファイル', 1, 'q_file', 'FILE'); configs.putObject('conf_DataIdB', fileDef); engine.setData(fileDef, files); configs.put('conf_SaveAs', fileName); return fileDef; }; /** * リクエストのテスト * @param expectedUrl * @param method */ const assertRequest = ({url, method}, expectedUrl) => { expect(url).toEqual(expectedUrl); expect(method).toEqual('GET'); }; /** * ファイルのテスト * @param file * @param name * @param contentType * @param body */ const assertFile = (file, name, contentType, encoding, body) => { expect(file.getName()).toEqual(name); expect(file.getContentType()).toEqual(contentType); let text = ''; fileRepository.readFile(file, encoding, line => text += line + '\n'); expect(text).toEqual(body); }; /** * 異常系のテスト * @param func * @param errorMsg */ const assertError = (func, errorMsg) => { let failed = false; try { main(); } catch (e) { failed = true; } if (!failed) { fail(); } }; /** * ファイル名が空でエラーになる場合 */ test('FileName is blank', () => { prepareConfigs(configs, 'https://example.com/test.pdf', null, '', ''); //