File Connector can perform file operations such as read, write, append, delete and list actions to a file.

This section will guide you on how to use and work with the File Connector.

Connector Configuration

No additional configuration is required for file connector

add_file_connector

Actions

read

Read a file form local file system

Request parameters
ParameterDescriptionrequired
actionaction to perform: readtrue
filePath of file to readtrue
readlinesread all bytes in a filefalse
Response parameters
ParameterDescriptionrequired
bodyResponse Body, data read from the filetrue
filePath of file to readtrue
Example
response = @call.connector("file_connector_name")
                .set("action","read")
                .set("file","/path/of/file/to/read")
                .set("readlines",false)
                .sync

response_file = response.get("file")  #File read
file_content = response.get("body")  #Response Body, data read from the file 

 

write

Write content to file

Request parameters
ParameterDescriptionrequired
actionaction to perform: writetrue
filePath of file to writetrue
datadata to be written to the filetrue
Example
response = @call.connector("file_connector_name")
                .set("action","write")
                .set("file","/file/to/write")
                .set("data","some data to write")
                .sync

 

append

Append content to file

Request parameters
ParameterDescriptionrequired
actionaction to perform: appendtrue
filePath of file to appendtrue
datadata to be appended to the filetrue
Example
response = @call.connector("file_connector_name")
                .set("action","append")
                .set("file","/file/to/append")
                .set("data","some data to append")
                .sync
 

delete

Delete a file

Request parameters
ParameterDescriptionrequired
actionaction to perform: deletetrue
filePath of file to deletetrue
Example

 

response = @call.connector("file_connector_name")
                .set("action","delete")
                .set("file","/file/to/delete")
                .sync
 

list

List of files and directories in a folder

Request parameters
ParameterDescriptionrequired
actionaction to perform: listtrue
filePath of file to listtrue
Example
response = @call.connector("file_connecor_name")
                .set("action","list")
                .set("file","/path/to/the directory/where files is to be listed")
                .sync
 

Connector request error handling

This is how success or failures can be handled for the connector requests within your Flintbit. This would help to take appropriate action if something failed.

if response.exitcode == 0               # 0 is success.
  puts "success"
  # take action in case of success
else                                    # non zero means fail
  puts "fail"
  puts "Reason:" + response.message     # get the reason of failure
  ## Take action in case of failure
end

On this page: