{"id":155302,"date":"2023-12-18T14:47:05","date_gmt":"2023-12-18T05:47:05","guid":{"rendered":"https:\/\/support.questetra.com\/?p=155302"},"modified":"2023-12-18T14:47:06","modified_gmt":"2023-12-18T05:47:06","slug":"service-task-aws-s3-file-download","status":"publish","type":"post","link":"https:\/\/support.questetra.com\/en\/bpmn-icons\/service-task-aws-s3-file-download\/","title":{"rendered":"Amazon S3: Download File"},"content":{"rendered":"\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"58\" data-attachment-id=\"113160\" data-permalink=\"https:\/\/support.questetra.com\/en\/developer-blog\/how-to-use-timer-start-event\/attachment\/advanced-banner-new-en\/\" data-orig-file=\"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2021\/05\/advanced-banner-new-en.png?fit=1200%2C68&amp;ssl=1\" data-orig-size=\"1200,68\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"advanced-banner-new-en\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2021\/05\/advanced-banner-new-en.png?fit=1024%2C58&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2021\/05\/advanced-banner-new-en-1024x58.png?resize=1024%2C58&#038;ssl=1\" alt=\"\" class=\"wp-image-113160\" srcset=\"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2021\/05\/advanced-banner-new-en.png?resize=1024%2C58&amp;ssl=1 1024w, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2021\/05\/advanced-banner-new-en.png?resize=600%2C34&amp;ssl=1 600w, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2021\/05\/advanced-banner-new-en.png?resize=768%2C44&amp;ssl=1 768w, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2021\/05\/advanced-banner-new-en.png?w=1200&amp;ssl=1 1200w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/figure>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading has-border-color has-product-main-border-color has-white-color has-product-main-background-color has-text-color has-background has-link-color\" style=\"border-width:2px;margin-top:0;margin-right:0;margin-bottom:0;margin-left:0;padding-top:var(--wp--preset--spacing--10);padding-right:var(--wp--preset--spacing--20);padding-bottom:var(--wp--preset--spacing--10);padding-left:var(--wp--preset--spacing--20)\"><strong>Amazon S3: Download File<\/strong><\/h4>\n\n\n\n<p class=\"has-text-align-right has-border-color has-product-main-border-color has-white-color has-product-main-background-color has-text-color has-background has-link-color has-small-font-size mt-0 pt-0 wp-block-paragraph\" style=\"border-width:2px;margin-top:0;margin-right:0;margin-bottom:0;margin-left:0;padding-top:0;padding-right:var(--wp--preset--spacing--20);padding-bottom:0;padding-left:var(--wp--preset--spacing--20)\"><a href=\"https:\/\/support.questetra.com\/en\/bpmn-icons\/service-task-aws-s3-file-download\/\">Amazon S3: \u30d5\u30a1\u30a4\u30eb\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9<\/a><\/p>\n\n\n\n<p class=\"has-border-color has-product-main-border-color has-text-color has-white-background-color has-background has-link-color mt-0 pt-0 wp-block-paragraph\" style=\"border-width:2px;margin-top:0;margin-right:0;margin-bottom:var(--wp--preset--spacing--30);margin-left:0;padding-top:var(--wp--preset--spacing--20);padding-right:var(--wp--preset--spacing--20);padding-bottom:var(--wp--preset--spacing--20);padding-left:var(--wp--preset--spacing--20)\">This item downloads the specified files on Amazon S3. You can download multiple files at once. When you download multiple files, you should write one Object Key per line.<\/p>\n\n\n\n<div class=\"wp-block-coblocks-accordion\">\n<div class=\"wp-block-coblocks-accordion-item\"><details open><summary class=\"wp-block-coblocks-accordion-item__title\">Basic Configs<\/summary><div class=\"wp-block-coblocks-accordion-item__content\">\n<dl style=\"0 0 -0.7em 0\">\n<dt style=\"font-weight: 300; font-size: 50%; margin: -1em 0 0 0; color: #C3C3C3;\"><\/dt><dd style=\"margin: -0.5em 0 0.1em 1em\">Step Name<\/dd>\n<dt style=\"font-weight: 300; font-size: 50%; margin: -1em 0 0 0; color: #C3C3C3;\"><\/dt><dd style=\"margin: -0.5em 0 0.1em 1em\">Note<\/dd>\n<\/dl>\n<\/div><\/details><\/div>\n<\/div>\n\n\n\n<figure class=\"wp-block-image alignright has-custom-border is-style-default\"><img decoding=\"async\" src=\"data:image;base64,\n        iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAABE9JREFUWEfN\n        l3tMlWUcxz\/v4SCXA38gtyPTiXo2m8YdEp3cUzGxOdw0E5tRNqlsMDGlRRE5kFJjqUDLKEJsYuCN\n        xD8qA5oMGeBhXpIdbiuRrORSkOKBt71vHuIcDnRU2un5893v8nl\/z\/f3e55HwMpLsDS\/V1CQo6Pe\n        MR6EKBECAG\/A5b5\/D9AhQBOI5weVg+VdDQ2DlsT+VwDvBZFqpXJkpyiwFbC3JChwRxAp0OsVOR1X\n        v+uezGdSgLl+YVtB2CuAysLERmYiDICY2qatKZjIf0IAjX9EniiKSQ+T2NRHEIR83aWql83FMgug\n        8Q8vEUWenYrkhhiCwFHdpeqN4+BMP0zln1tSCaMKSHsuIORP5Z+bxhIRk8ZqYhRAUrvCdkT3sIKz\n        FFoS5sg9hcbQHaMAGt\/wD0SBZEsDPYqdIJKra65OkWLIANKQcdCrfjPt85zMXcTGRGCjtGFo6B6f\n        lRwnfMkibv58i2073ubwwRw8Pdx4bUcGcbHRrIlbQfnpc2xcvwZnJxV37w6Rd7iYwuJSU947fyoH\n        XKVhJQNo\/MISRIRiU6uQQF96evvRtXXw8YE9eKk9adG147NwPum79\/Hum9txUqnI2nuQVSuiUXu6\n        09f\/OwqFgoQtycya6SWH\/PGnrnEFExA36bQ1R+4DhH8iQqKp1aJgf57bsJaZXmpEUcTe3o6S0lO8\n        tHkDpScqeGp5FPrhYWrrGglbEkJ9YzNKpZLVK2PQtXVypvJrjpVXMDAwfioLUKjTVr8gA8zzC2\/k\n        7\/k+uubMnkVBbha9fX18efIsq2JjUHu48Xp6Nvuz07n1y69Ms53GjZvduLtNZ4bak4MfFVF2upLl\n        0WGsfXoli58I5JuqC6SkZZqTTFOrtjrQAHB7zMEiG0vO72Wmcb6mls+\/KCd3z1s4ONjz4qs72ZWS\n        xJLQICrOfUvXzW6eT1jHja5unkncxrKopVy+2iLrpCh\/H38MDLA5KdUcQE+rtnq6AUA0Z7E7PZWV\n        yyLR6\/VcbNDi4e5Kbl4hPgvmy1tTeKSU1vZOMtJSqG\/UytU58P47LF0cwjRbW2739PJhwaccP3nW\n        bNO0aquFSQEepdUs8R0LMG4LUrdtoa5BS82Fi5bEMrKRxCkJVaqYnZ0dZacqydp3yDSO0RaME6HU\n        AW9sf0Uuf+mJr2Q1P8haHx\/HDLUHi4IDaL58jez9eabu\/4hQ42e+DVUqRzJ2JbMseinDwyNcu66j\n        SXuFKz+0UFNbP9pekl3Y4hCCA3zxffwx5s2ZTW9fP8fKzrDiyQhZB1Xf1xkBGLXhRIPI4KGZ603i\n        pnVEhoXi6uKCjY3CbDGkyXdd1yYnlioWvzoWZ2cVRUfLJh9EE41ic1mkaRcaEoC\/z0KcVI6yia69\n        k+strXLLWriMR7HkZNXDSAKw+nEsQVj1QjIquCm8jJrqwdzl9P93Kf0vKvHA13IDhFUfJgYIqz7N\n        xorIao9TCyfbQ5v9BWbg5jDAzldXAAAAAElFTkSuQmCC\n    \" alt=\"Auto Step icon\" class=\"has-border-color has-ast-global-color-4-border-color\" style=\"border-width:0.5em\"\/><\/figure>\n\n\n\n<div class=\"wp-block-coblocks-accordion\">\n<div class=\"wp-block-coblocks-accordion-item\"><details open><summary class=\"wp-block-coblocks-accordion-item__title\">Configs for this Auto Step<\/summary><div class=\"wp-block-coblocks-accordion-item__content\">\n<dl style=\"0 0 -0.7em 0\">\n<dt style=\"font-weight: 300; font-size: 50%; margin: -1em 0 0 0; color: #aaa;\">conf_AccessKey<\/dt><dd style=\"margin: -0.5em 0 0.1em 1em\">C1: Access Key<span style=\"color:#990000;\"> *<\/span><\/dd>\n<dt style=\"font-weight: 300; font-size: 50%; margin: -1em 0 0 0; color: #aaa;\">conf_SecretKey<\/dt><dd style=\"margin: -0.5em 0 0.1em 1em\">C2: Secret Access Key<span style=\"color:#990000;\"> *<\/span><\/dd>\n<dt style=\"font-weight: 300; font-size: 50%; margin: -1em 0 0 0; color: #aaa;\">conf_Region<\/dt><dd style=\"margin: -0.5em 0 0.1em 1em\">C3: Region Code<span style=\"color:#990000;\"> *<\/span><\/dd>\n<dt style=\"font-weight: 300; font-size: 50%; margin: -1em 0 0 0; color: #aaa;\">conf_Bucket<\/dt><dd style=\"margin: -0.5em 0 0.1em 1em\">C4: Bucket Name<span style=\"color:#990000;\"> *<\/span><\/dd>\n<dt style=\"font-weight: 300; font-size: 50%; margin: -1em 0 0 0; color: #aaa;\">conf_Keys<\/dt><dd style=\"margin: -0.5em 0 0.1em 1em\">C5: Object Keys of the files to download<span style=\"color:#990000;\"> *<\/span><\/dd>\n<dt style=\"font-weight: 300; font-size: 50%; margin: -1em 0 0 0; color: #aaa;\">conf_Files<\/dt><dd style=\"margin: -0.5em 0 0.1em 1em\">C6: Data item to add the downloaded files<span style=\"color:#990000;\"> *<\/span><\/dd>\n\n<\/dl>\n<\/div><\/details><\/div>\n<\/div>\n\n\n\n<h3 class=\"wp-block-heading\" style=\"margin-top:var(--wp--preset--spacing--30)\"><span>Notes<\/span><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>To learn about how to create your Access Key and Secret Access Key, see the\u00a0<a href=\"https:\/\/docs.aws.amazon.com\/IAM\/latest\/UserGuide\/id_credentials_access-keys.html\" target=\"_blank\" rel=\"noreferrer noopener\">Amazon Web Services Documentation<\/a><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" style=\"margin-top:var(--wp--preset--spacing--30)\"><span>Capture<\/span><\/h3>\n\n\n\n<figure class=\"wp-block-image size-full has-custom-border is-style-rounded is-style-rounded--1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1416\" height=\"1448\" data-attachment-id=\"155303\" data-permalink=\"https:\/\/support.questetra.com\/en\/incident\/trouble-20240124\/attachment\/aws-s3-file-download_capture_en\/\" data-orig-file=\"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2023\/12\/aws-s3-file-download_capture_en.png?fit=1416%2C1448&amp;ssl=1\" data-orig-size=\"1416,1448\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"aws-s3-file-download_capture_en\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2023\/12\/aws-s3-file-download_capture_en.png?fit=616%2C630&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2023\/12\/aws-s3-file-download_capture_en.png?resize=1416%2C1448&#038;ssl=1\" alt=\"\" class=\"has-border-color wp-image-155303\" style=\"border-color:#009900;border-width:3px;border-radius:9px\" srcset=\"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2023\/12\/aws-s3-file-download_capture_en.png?w=1416&amp;ssl=1 1416w, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2023\/12\/aws-s3-file-download_capture_en.png?resize=308%2C315&amp;ssl=1 308w, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2023\/12\/aws-s3-file-download_capture_en.png?resize=616%2C630&amp;ssl=1 616w, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2023\/12\/aws-s3-file-download_capture_en.png?resize=768%2C785&amp;ssl=1 768w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" style=\"margin-top:var(--wp--preset--spacing--30)\"><span>See also<\/span><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/support.questetra.com\/en\/bpmn-icons\/intermediate-error-catch-event-boundary-type\/\" target=\"_blank\" rel=\"noreferrer noopener\">Intermediate Error Catch Event (Boundary Type)<\/a><\/li>\n<\/ul>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-coblocks-accordion\">\n<div class=\"wp-block-coblocks-accordion-item\"><details><summary class=\"wp-block-coblocks-accordion-item__title\">Script (click to open)<\/summary><div class=\"wp-block-coblocks-accordion-item__content\">\n<ul class=\"wp-block-list\">\n<li>An XML file that contains the code below is available to download\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/raw.githubusercontent.com\/Questetra\/Addon-XML\/release-2023-12-08\/aws-s3-file-download.xml\" target=\"_blank\" rel=\"noreferrer noopener\">aws-s3-file-download.xml<\/a> (C) Questetra, Inc. (MIT License)<\/li>\n\n\n\n<li>If you are using Professional, you can modify the contents of this file and use it as your own add-on auto step<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-js\" data-lang=\"JavaScript\"><code>\nconst MAX_OBJECT_KEY_BYTES = 1024;\n\nfunction main() {\n    \/\/\/\/\/\/ == \u5de5\u7a0b\u30b3\u30f3\u30d5\u30a3\u30b0\u30fb\u30ef\u30fc\u30af\u30d5\u30ed\u30fc\u30c7\u30fc\u30bf\u306e\u53c2\u7167 \/ Config & Data Retrieving ==\n    const awsKey = configs.getObject(&quot;conf_AccessKey&quot;).getToken();\n    const awsSecret = configs.getObject(&quot;conf_SecretKey&quot;).getToken();\n    const region = retrieveRegion();\n    const bucket = retrieveBucket();\n    const objectKeys = retrieveObjectKeys();\n\n    \/\/\/\/\/\/ == \u6f14\u7b97 \/ Calculating ==\n    if (objectKeys.length === 0) {\n        return;\n    }\n\n    const fileDef = configs.getObject(&quot;conf_Files&quot;);\n    const files = engine.findData(fileDef) ?? new java.util.ArrayList();\n    objectKeys.forEach(objectKey =&gt; {\n        const newFile = downloadFile(awsKey, awsSecret, region, bucket, objectKey);\n        files.add(newFile);\n    });\n    engine.setData(fileDef, files);\n}\n\n\/**\n * config \u304b\u3089\u30ea\u30fc\u30b8\u30e7\u30f3\u30b3\u30fc\u30c9\u3092\u8aad\u307f\u51fa\u3059\n * \u30ea\u30fc\u30b8\u30e7\u30f3\u30b3\u30fc\u30c9\u306e\u5f62\u5f0f\u3068\u3057\u3066\u4e0d\u6b63\u306a\u5834\u5408\u306f\u30a8\u30e9\u30fc\n * @return {String}\n *\/\nfunction retrieveRegion() {\n    const region = configs.get(&quot;conf_Region&quot;);\n    \/\/ \u4eca\u5f8c\u30ea\u30fc\u30b8\u30e7\u30f3\u304c\u5897\u3048\u308b\u3053\u3068\u3082\u8003\u3048\u3066\u3001\u4e2d\u592e\u306e\u6700\u5927\u6587\u5b57\u6570\u306b\u306f\u4f59\u88d5\u3092\u307f\u3066\u3044\u308b\n    const reg = new RegExp(&quot;^[a-z]{2}-[a-z]{4,16}-[1-9]$&quot;);\n    if (!reg.test(region)) {\n        throw new Error(&quot;Region Code is invalid.&quot;);\n    }\n    return region;\n}\n\n\/**\n * form-type=&quot;SELECT&quot; editable=&quot;true&quot;\n * \u306e\u8a2d\u5b9a\u5024\u3092\u8aad\u307f\u51fa\u3059\n * @return {String}\n *\/\nfunction getConfSelectValue(configName) {\n    const def = configs.getObject(configName);\n    if (def === null) {\n        return configs.get(configName);\n    }\n    return engine.findData(def) ?? &quot;&quot;;\n}\n\n\/**\n * config \u304b\u3089\u30d0\u30b1\u30c3\u30c8\u540d\u3092\u8aad\u307f\u51fa\u3059\n * \u30d0\u30b1\u30c3\u30c8\u540d\u306e\u5f62\u5f0f\u3068\u3057\u3066\u4e0d\u6b63\u306a\u5834\u5408\u306f\u30a8\u30e9\u30fc\n * @return {String}\n *\/\nfunction retrieveBucket() {\n    const bucket = getConfSelectValue(&quot;conf_Bucket&quot;);\n    if (bucket === &quot;&quot;) {\n        throw new Error(&quot;Bucket Name is blank.&quot;);\n    }\n    const reg = new RegExp(&quot;^[0-9a-z][0-9a-z-.]{1,61}[0-9a-z]$&quot;);\n    if (!reg.test(bucket) || bucket.includes(&quot;..&quot;)) {\n        throw new Error(&quot;Bucket Name is invalid.&quot;);\n    }\n    return bucket;\n}\n\n\/**\n * config \u304b\u3089\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u30ad\u30fc\u3092\u8aad\u307f\u51fa\u3059\n * @return {Array&lt;String&gt;}\n *\/\nfunction retrieveObjectKeys() {\n    const keyStr = getConfSelectValue(&quot;conf_Keys&quot;);\n    const keys = keyStr.split(&quot;\\n&quot;).filter(key =&gt; key.length !== 0); \/\/ \u7a7a\u884c\u306f\u8aad\u307f\u98db\u3070\u3059\u3002\n    keys.forEach(key =&gt; {\n        if (encodeURIComponent(key).replace(\/%..\/g, &quot;x&quot;).length &gt; MAX_OBJECT_KEY_BYTES) {\n            throw new Error(`The object key &quot;${key}&quot; is too long. Object key must be less than ${MAX_OBJECT_KEY_BYTES} bytes.`);\n        }\n        if(key.endsWith(&#39;\/&#39;)) {\n            throw new Error(`The object key &quot;${key}&quot; is invalid. Object key must not end with a slash.`);\n        }\n    });\n    if (keys.length &gt; httpClient.getRequestingLimit()) {\n        throw new Error(&quot;The number of object keys exceeds the limit.&quot;);\n    }\n\n    return keys;\n}\n\n\/**\n * \u4fdd\u5b58\u6642\u306e\u30d5\u30a1\u30a4\u30eb\u540d\u306e\u6700\u5927\u9577\n *\/\nconst FILE_NAME_MAX_LENGTH = 200;\n\n\/**\n * \u30d5\u30a1\u30a4\u30eb\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\n * @param key \u30a2\u30af\u30bb\u30b9\u30ad\u30fc\n * @param secret \u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u30a2\u30af\u30bb\u30b9\u30ad\u30fc\n * @param region \u30ea\u30fc\u30b8\u30e7\u30f3\n * @param bucket \u30d0\u30b1\u30c3\u30c8\n * @param objectKey \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u30ad\u30fc\n *\/\nfunction downloadFile(key, secret, region, bucket, objectKey) {\n    const encodedObjectKey = encodeURIComponent(objectKey);\n    const url = `https:\/\/${bucket}.s3.${region}.amazonaws.com\/${encodedObjectKey}`;\n    const response = httpClient.begin()\n        .awsSignV4(key, secret, region, &quot;s3&quot;)\n        .header(&quot;x-amz-checksum-mode&quot;, &quot;ENABLED&quot;)\n        .get(url);\n    const status = response.getStatusCode();\n    if (status !== 200) {\n        engine.log(response.getResponseAsString());\n        throw new Error(`Failed to download &quot;${objectKey}&quot; from S3. status: ${status}`);\n    }\n\n    const data = response.getResponse();\n    \/\/ SHA-256 \u304b SHA-1 \u306e\u30c1\u30a7\u30c3\u30af\u30b5\u30e0\u304c\u3042\u308b\u5834\u5408\u3001\u691c\u8a3c\n    validateChecksum(objectKey, response, &quot;x-amz-checksum-sha256&quot;, () =&gt; digest.sha256(data));\n    validateChecksum(objectKey, response, &quot;x-amz-checksum-sha1&quot;, () =&gt; digest.sha1(data));\n\n    let fileName = objectKey.split(&quot;\/&quot;).pop();\n    if(fileName.length &gt; FILE_NAME_MAX_LENGTH) {\n        fileName = fileName.substring(0, FILE_NAME_MAX_LENGTH-3) + &quot;...&quot;;\n    }\n    return new com.questetra.bpms.core.event.scripttask.NewQfile(\n        fileName,\n        response.getContentType(),\n        data\n    );\n}\n\n\/**\n * \u30c1\u30a7\u30c3\u30af\u30b5\u30e0\u306e\u691c\u8a3c\n * @param objectKey \u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u30ad\u30fc\n * @param response \u30ec\u30b9\u30dd\u30f3\u30b9\n * @param headerName \u30c1\u30a7\u30c3\u30af\u30b5\u30e0\u30d8\u30c3\u30c0\u30fc\u540d\n * @param calculate \u30c1\u30a7\u30c3\u30af\u30b5\u30e0\u3092\u8a08\u7b97\u3059\u308b\u95a2\u6570\n *\/\nfunction validateChecksum(objectKey, response, headerName, calculate) {\n    let checksumHeaders = response.getHeaderValues(headerName);\n    if (checksumHeaders.isEmpty()) {\n        return;\n    }\n    const checksum = checksumHeaders.get(0);\n    const calculated = base64.encodeToString(calculate());\n    if (checksum !== calculated) {\n        throw new Error(`The checksum of the downloaded file &quot;${objectKey}&quot; does not match. s3: ${checksum}, file: ${calculated}`);\n    }\n    engine.log(`Checksum of &quot;${objectKey}&quot; is OK. ${checksum}`);\n}\n    <\/code><\/pre><\/div>\n<\/div><\/details><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>This item downloads the specified files on Amazon S3. You can download multiple files at once. When you download multiple files, you should write one Object Key per line.<\/p>\n","protected":false},"author":17,"featured_media":155421,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","_uag_custom_page_level_css":"","advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_seo_schema_type":"","_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_wpcom_ai_launchpad_first_post":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"{title}\n\n{excerpt}\n\n{url}","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"_wpas_customize_per_network":false,"jetpack_post_was_ever_published":false},"categories":[551],"tags":[],"faq_section":[],"class_list":["post-155302","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bpmn-icons"],"jetpack_publicize_connections":[],"uagb_featured_image_src":{"full":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2023\/12\/bpmn-icon-service-task-aws.png?fit=1200%2C675&ssl=1",1200,675,false],"thumbnail":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2023\/12\/bpmn-icon-service-task-aws.png?resize=440%2C440&ssl=1",440,440,true],"medium":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2023\/12\/bpmn-icon-service-task-aws.png?fit=560%2C315&ssl=1",560,315,true],"medium_large":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2023\/12\/bpmn-icon-service-task-aws.png?fit=768%2C432&ssl=1",768,432,true],"large":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2023\/12\/bpmn-icon-service-task-aws.png?fit=1024%2C576&ssl=1",1024,576,true],"1536x1536":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2023\/12\/bpmn-icon-service-task-aws.png?fit=1200%2C675&ssl=1",1200,675,true],"2048x2048":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2023\/12\/bpmn-icon-service-task-aws.png?fit=1200%2C675&ssl=1",1200,675,true],"newspack-article-block-landscape-large":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2023\/12\/bpmn-icon-service-task-aws.png?resize=1200%2C675&ssl=1",1200,675,true],"newspack-article-block-portrait-large":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2023\/12\/bpmn-icon-service-task-aws.png?resize=900%2C675&ssl=1",900,675,true],"newspack-article-block-square-large":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2023\/12\/bpmn-icon-service-task-aws.png?resize=1200%2C675&ssl=1",1200,675,true],"newspack-article-block-landscape-medium":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2023\/12\/bpmn-icon-service-task-aws.png?resize=800%2C600&ssl=1",800,600,true],"newspack-article-block-portrait-medium":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2023\/12\/bpmn-icon-service-task-aws.png?resize=600%2C675&ssl=1",600,675,true],"newspack-article-block-square-medium":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2023\/12\/bpmn-icon-service-task-aws.png?resize=800%2C675&ssl=1",800,675,true],"newspack-article-block-landscape-intermediate":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2023\/12\/bpmn-icon-service-task-aws.png?resize=600%2C450&ssl=1",600,450,true],"newspack-article-block-portrait-intermediate":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2023\/12\/bpmn-icon-service-task-aws.png?resize=450%2C600&ssl=1",450,600,true],"newspack-article-block-square-intermediate":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2023\/12\/bpmn-icon-service-task-aws.png?resize=600%2C600&ssl=1",600,600,true],"newspack-article-block-landscape-small":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2023\/12\/bpmn-icon-service-task-aws.png?resize=400%2C300&ssl=1",400,300,true],"newspack-article-block-portrait-small":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2023\/12\/bpmn-icon-service-task-aws.png?resize=300%2C400&ssl=1",300,400,true],"newspack-article-block-square-small":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2023\/12\/bpmn-icon-service-task-aws.png?resize=400%2C400&ssl=1",400,400,true],"newspack-article-block-landscape-tiny":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2023\/12\/bpmn-icon-service-task-aws.png?resize=200%2C150&ssl=1",200,150,true],"newspack-article-block-portrait-tiny":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2023\/12\/bpmn-icon-service-task-aws.png?resize=150%2C200&ssl=1",150,200,true],"newspack-article-block-square-tiny":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2023\/12\/bpmn-icon-service-task-aws.png?resize=200%2C200&ssl=1",200,200,true],"newspack-article-block-uncropped":["https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2023\/12\/bpmn-icon-service-task-aws.png?fit=1200%2C675&ssl=1",1200,675,true]},"uagb_author_info":{"display_name":"Shiho Tatsumi","author_link":"https:\/\/support.questetra.com\/en\/author\/tatsumi48c607ec82\/"},"uagb_comment_info":0,"uagb_excerpt":"This item downloads the specified files on Amazon S3. You can download multiple files at once. When you download multiple files, you should write one Object Key per line.","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9DiIh-EoS","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":76390,"url":"https:\/\/support.questetra.com\/en\/bpmn-icons\/service-task-google-drive-file-upload\/","url_meta":{"origin":155302,"position":0},"title":"Google Drive: File Upload","author":"Hirotaka NISHI","date":"2019-04-23","format":false,"excerpt":"Uploads files specified in File Type Data Item to the specified folder of Google Drive. Capable of obtaining the file ID, the display URL, and the download URL as the response and storing them in a String type Data Item.","rel":"","context":"In &quot;BPMN Icons&quot;","block_context":{"text":"BPMN Icons","link":"https:\/\/support.questetra.com\/en\/category\/bpmn-icons\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2024\/12\/bpmn-icon-service-task-google-drive2024.png?fit=1200%2C675&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2024\/12\/bpmn-icon-service-task-google-drive2024.png?fit=1200%2C675&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2024\/12\/bpmn-icon-service-task-google-drive2024.png?fit=1200%2C675&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2024\/12\/bpmn-icon-service-task-google-drive2024.png?fit=1200%2C675&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2024\/12\/bpmn-icon-service-task-google-drive2024.png?fit=1200%2C675&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":79746,"url":"https:\/\/support.questetra.com\/en\/data-items\/file-type\/","url_meta":{"origin":155302,"position":1},"title":"File-Type","author":"Peter Glover","date":"2019-09-30","format":false,"excerpt":"Displays a button for selecting and uploading files.","rel":"","context":"In &quot;Data Items&quot;","block_context":{"text":"Data Items","link":"https:\/\/support.questetra.com\/en\/category\/data-items\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2019\/09\/File.png?fit=1200%2C675&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2019\/09\/File.png?fit=1200%2C675&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2019\/09\/File.png?fit=1200%2C675&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2019\/09\/File.png?fit=1200%2C675&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2019\/09\/File.png?fit=1200%2C675&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":84047,"url":"https:\/\/support.questetra.com\/en\/developer-blog\/download-process-file\/","url_meta":{"origin":155302,"position":2},"title":"Download Case Files Using the Workflow API","author":"Peter Glover","date":"2020-05-22","format":false,"excerpt":"Here is a script that searches for a Case that matches the conditions and downloads the file attached to the Case.","rel":"","context":"In &quot;Questetra Developers Blog&quot;","block_context":{"text":"Questetra Developers Blog","link":"https:\/\/support.questetra.com\/en\/category\/developer-blog\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2020\/01\/workflow-api-file-download-featured-image.png?fit=1200%2C675&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2020\/01\/workflow-api-file-download-featured-image.png?fit=1200%2C675&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2020\/01\/workflow-api-file-download-featured-image.png?fit=1200%2C675&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2020\/01\/workflow-api-file-download-featured-image.png?fit=1200%2C675&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2020\/01\/workflow-api-file-download-featured-image.png?fit=1200%2C675&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":96192,"url":"https:\/\/support.questetra.com\/en\/developer-blog\/onedrive-workflow-tutorial\/","url_meta":{"origin":155302,"position":3},"title":"Utilising OneDrive from Your Workflow","author":"Hirotaka NISHI","date":"2020-10-13","format":false,"excerpt":"We will describe some automated Tasks related to Microsoft 365 OneDrive for Business. Users can create folders and upload files to OneDrive.","rel":"","context":"In &quot;Questetra Developers Blog&quot;","block_context":{"text":"Questetra Developers Blog","link":"https:\/\/support.questetra.com\/en\/category\/developer-blog\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2020\/09\/OneDrive-1.png?fit=1200%2C675&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2020\/09\/OneDrive-1.png?fit=1200%2C675&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2020\/09\/OneDrive-1.png?fit=1200%2C675&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2020\/09\/OneDrive-1.png?fit=1200%2C675&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2020\/09\/OneDrive-1.png?fit=1200%2C675&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":74763,"url":"https:\/\/support.questetra.com\/en\/developer-blog\/google-drive-items\/","url_meta":{"origin":155302,"position":4},"title":"Utilizing Google Drive from Workflow &#8211; Sending files to people outside the company","author":"Hirotaka NISHI","date":"2020-10-30","format":false,"excerpt":"Google Drive is a cloud storage service offered by Google. I will explain automatic Step for utilizing Google Drive in a Workflow App.","rel":"","context":"In \"Google Drive API v3\"","block_context":{"text":"Google Drive API v3","link":"https:\/\/support.questetra.com\/en\/tag\/google-drive-api-v3\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2020\/10\/google-drive-questetra.png?fit=1200%2C675&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2020\/10\/google-drive-questetra.png?fit=1200%2C675&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2020\/10\/google-drive-questetra.png?fit=1200%2C675&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2020\/10\/google-drive-questetra.png?fit=1200%2C675&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2020\/10\/google-drive-questetra.png?fit=1200%2C675&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":95321,"url":"https:\/\/support.questetra.com\/en\/developer-blog\/box-workflow-tutorial\/","url_meta":{"origin":155302,"position":5},"title":"Utilising Box From Your Workflow","author":"Peter Glover","date":"2026-08-18","format":false,"excerpt":"Describes the automatic Steps that links Questetra to Box. You can Upload files, Create folders, and so on.","rel":"","context":"In &quot;Questetra Developers Blog&quot;","block_context":{"text":"Questetra Developers Blog","link":"https:\/\/support.questetra.com\/ja\/category\/developer-blog\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2020\/09\/eyecatch-box.png?fit=1200%2C675&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2020\/09\/eyecatch-box.png?fit=1200%2C675&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2020\/09\/eyecatch-box.png?fit=1200%2C675&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2020\/09\/eyecatch-box.png?fit=1200%2C675&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2020\/09\/eyecatch-box.png?fit=1200%2C675&ssl=1&resize=1050%2C600 3x"},"classes":[]}],"amp_enabled":false,"jetpack_featured_media_url":"https:\/\/i0.wp.com\/support.questetra.com\/wp-content\/uploads\/2023\/12\/bpmn-icon-service-task-aws.png?fit=1200%2C675&ssl=1","_links":{"self":[{"href":"https:\/\/support.questetra.com\/en\/wp-json\/wp\/v2\/posts\/155302","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/support.questetra.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/support.questetra.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/support.questetra.com\/en\/wp-json\/wp\/v2\/users\/17"}],"replies":[{"embeddable":true,"href":"https:\/\/support.questetra.com\/en\/wp-json\/wp\/v2\/comments?post=155302"}],"version-history":[{"count":2,"href":"https:\/\/support.questetra.com\/en\/wp-json\/wp\/v2\/posts\/155302\/revisions"}],"predecessor-version":[{"id":155309,"href":"https:\/\/support.questetra.com\/en\/wp-json\/wp\/v2\/posts\/155302\/revisions\/155309"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/support.questetra.com\/en\/wp-json\/wp\/v2\/media\/155421"}],"wp:attachment":[{"href":"https:\/\/support.questetra.com\/en\/wp-json\/wp\/v2\/media?parent=155302"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/support.questetra.com\/en\/wp-json\/wp\/v2\/categories?post=155302"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/support.questetra.com\/en\/wp-json\/wp\/v2\/tags?post=155302"},{"taxonomy":"faq_section","embeddable":true,"href":"https:\/\/support.questetra.com\/en\/wp-json\/wp\/v2\/faq_section?post=155302"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}