DataPower

DataPower

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

Read Binary File using a GatewayScript

  • 1.  Read Binary File using a GatewayScript

    Posted Wed February 03, 2021 08:32 AM

    Hi,

    I have implemented the below code in an attempt to get the contents of a binary file to store in a variable for later processing in the response rule but I only get the first line of the binary file instead of the whole content, please assist in where I might be going wrong.

    var ctx = session.name('myContext') || session.createContext('myContext');

    session.input.readAsBuffer(function (error, buffer) {

    if (error)

    {

    // handle error

    session.output.write (error.errorMessage);

    } else {

    /* write the default output buffer*/

    const testvar = buffer;

    ctx.setVariable('binary', testvar.toString());

    session.output.write (buffer);

    }

    });



    #DataPower
    #Support
    #SupportMigration


  • 2.  RE: Read Binary File using a GatewayScript

    Posted Thu February 04, 2021 12:06 PM

    Hi,

    the code seems to work just fine, at least for firmware IDG.10.0.0.1. How large is the binary you are trying to store n the context variable?

    --HP



    #DataPower
    #Support
    #SupportMigration