IFS API

IFS API

Overview

The IFS APIs read, write, and locate files in the IBM i Integrated File System (IFS) from a Profound.js module. The file operations themselves are performed on the IBM i system by the Profound.js Connector, so every path passed to these APIs refers to the IFS of the IBM i system that the Profound.js instance is connected to.

Because the data is exchanged with the IBM i as raw bytes, the read and write APIs accept an optional CCSID (Coded Character Set Identifier) so that text can be converted between the encoding used in the file and the encoding used by your JavaScript code. The same CCSID conventions are used by all of the IFS APIs:

  • 0 (or omitted) - The CCSID of the IBM i job is used.

  • 65535 - No conversion is performed. Use this for binary files such as PDFs or images, or when the data is already in the encoding you need.

  • 1208 - UTF-8. This is the encoding Node.js uses for JavaScript strings, so it is the most common choice when converting file contents to and from a String.

  • 37 - EBCDIC (US English). Other EBCDIC CCSIDs, such as 500 or 1141, can be used in the same way.

pjs.readIFSFile() and pjs.writeIFSFile() handle the entire file in a single call and exchange the data as a Node.js Buffer. For files that are not on the IBM i IFS (for example, files local to a Profound.js instance running on Windows or Linux), use the standard Node.js fs module instead.

Available APIs

API

Purpose

API

Purpose

pjs.findIFSFile()

Searches a list of directories for a file and returns the first directory that contains it.

pjs.readIFSFile()

Reads the entire contents of an IFS file into a Buffer, with optional CCSID conversion.

pjs.writeIFSFile()

Creates (or replaces) an IFS file from a Buffer, with optional CCSID conversion.

Requirements

These APIs require the Profound.js Connector module.


Related Pages