ballerina/file package
Package overview
This package contains services that register listeners against a local folder and identify events that create, modify, and delete files.
Samples
The sample given below shows how an endpoint is used to listen to the local folder. The onCreate()
resource method gets invoked when a file is created inside the target/fs
folder. Use the onDelete()
and onModify()
methods to listen to the delete and modify events.
import ballerina/file;
endpoint file:Listener localFolder {
path:"target/fs"
};
service fileSystem bind localFolder {
onCreate (file:FileEvent m) {
}
}
Records Summary
Record | Description | ||
---|---|---|---|
FileEvent | Represents an event which will trigger when there is a changes to listining direcotry. | ||
ListenerEndpointConfiguration | Represents configurations that required for directory listener. |
Endpoints Summary
Endpoint | Description | ||
---|---|---|---|
Listener | Represents directory listener endpoint where used to listen to a directory in the local file system. |
public type FileEvent
Represents an event which will trigger when there is a changes to listining direcotry.
Field Name | Data Type | Default Value | Description |
---|---|---|---|
name | string | Absolute file URI for triggerd event |
|
operation | string | Triggered event action. This can be create, delete or modify |
public type ListenerEndpointConfiguration
Represents configurations that required for directory listener.
Field Name | Data Type | Default Value | Description |
---|---|---|---|
path | string | Directory path which need to listen |
|
recursive | boolean | false | Recursively monitor all sub folders or not in the given direcotry path |
Endpoint Listener
Represents directory listener endpoint where used to listen to a directory in the local file system.