-
-
Notifications
You must be signed in to change notification settings - Fork 73
Rule Engine
Tip: For detailed documentation refer to the IntelliSense tips that appear when you call a given API method.
These Polycloud API methods currently support the rule engine.
-
IStore.UploadDirectory()
-
IStore.DownloadDirectory()
Rules allow you to declaratively specify which files and folders should be copied and which should be skipped. There are rules that let you filter on file extension (eg: upload only PDF files) or folder name (eg: skip folders called "node_modules") and various other parameters.
Only files that pass all the rules are copied from the source to the target.
The rules that are supported are listed here:
| Rule Class | Parameters | Description |
|---|---|---|
| ExtensionRule | extensions |
Only transfer files of a certain extension, or blacklist files of a certain extension. |
| ObjectNameRule | names |
Only transfer objects of a certain name, or blacklist files of a certain name |
| DirectoryNameRule | names |
Only transfer folders of a certain name, or blacklist folders of a certain name |
| FullPathRule | names |
Only transfer objects that contain the given path(s), or blacklist objects that contain the given path(s) |
| ObjectNameRegexRule | regexPatterns |
Only transfer objects whose names match the given regular expression(s), or blacklist files that match |
| DirectoryNameRegexRule | regexPatterns |
Only transfer folders whose names match the given regular expression(s), or blacklist folders that match |
| FullPathRule | names |
Only transfer objects whose full paths match the given regular expression(s), or blacklist files that match |
Declare the rules and then call DownloadDirectory or UploadDirectory with those rules:
var rules = new List<StorageRule>{
new ExtensionRule(true, new List<string>{ "pdf" }), // only allow PDF files
new DirectoryNameRule(true, "attachments ") // only allow anything in the "attachments" folder
};
await client.DownloadDirectory(@"/user/home/attachments", @"C:\attachments\", StorageExistsMode.Skip, null, rules);Declare the rules and then call DownloadDirectory or UploadDirectory with those rules:
// this uses the pre-defined blacklist that skips directories named `.git`, `.svn`, `node_modules` etc
var rules = new List<StorageRule>{
new DirectoryNameRule(false, DirectoryNameRule.CommonBlacklistedFolders),
};
await client.DownloadDirectory(@"/user/home/attachments", @"C:\attachments\", StorageExistsMode.Skip, null, rules);