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.
endpoint file:Listener localFolder {
path:"target/fs"
};
service fileSystem bind localFolder {
onCreate (file:FileEvent m) {
}
}
Package content
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. |
Objects Summary
Object | 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 |
public type Listener object
Represents directory listener endpoint where used to listen to a directory in the local file system.
-
<Listener> init(ListenerEndpointConfiguration config)
Parameter Name Data Type Default Value Description config ListenerEndpointConfiguration -
<Listener> register(typedesc serviceType)
Parameter Name Data Type Default Value Description serviceType typedesc -
<Listener> start()
-
<Listener> stop()