|
| 1 | +FileFetchTask |
| 2 | +======== |
| 3 | + |
| 4 | +Perform copy between 2 flysystems storage |
| 5 | + |
| 6 | +Task reference |
| 7 | +-------------- |
| 8 | + |
| 9 | +* **Service**: [`CleverAge\FlysystemProcessBundle\Task\FileFetchTask`](../src/Task/FileFetchTask.php) |
| 10 | + |
| 11 | +Accepted inputs |
| 12 | +--------------- |
| 13 | + |
| 14 | +The filename or filenames to copy from. |
| 15 | + |
| 16 | +If the option `file_pattern` is not set the input is used as strict filename(s) to match. |
| 17 | + |
| 18 | +If input is set but not corresponding as any file into `source_filesystem` task failed with UnableToReadFile exception. |
| 19 | + |
| 20 | +If FileFetchTask is the fisrt task of you process and you wan to use input, don't forgive to set the `entry_point` task name at process level |
| 21 | + |
| 22 | +Possible outputs |
| 23 | +---------------- |
| 24 | + |
| 25 | +Filename of copied file. |
| 26 | + |
| 27 | +Options |
| 28 | +------- |
| 29 | + |
| 30 | +| Code | Type | Required | Default | Description | |
| 31 | +|--------------------------|:----------:|:---------:|:---------:|-----------------------------------------------------------------------------------------------------------------------------------------------| |
| 32 | +| `source_filesystem` | `string` | **X** | | The source flysystem/storage.<br/>See config/packages/flysystem.yaml to see configured flysystem/storages. | |
| 33 | +| `destination_filesystem` | `string` | **X** | | The source flysystem/storage.<br/>See config/packages/flysystem.yaml to see configured flysystem/storages. | |
| 34 | +| `file_pattern` | `string` | | null | The file_parttern used in preg_match to match into `source_filesystem` list of files. If not set try to use input as strict filename to match | |
| 35 | +| `remove_source` | `bool` | | false | If true delete source file after copy | |
| 36 | + |
| 37 | + |
| 38 | +Examples |
| 39 | +-------- |
| 40 | + |
| 41 | +* Simple fetch task configuration |
| 42 | + - See config/packages/flysystem.yaml to see configured flysystems/storages. |
| 43 | + - copy all .csv files from 'storage.source' to 'storage.destination' |
| 44 | + - remove .csv from 'storage.source' after copy |
| 45 | + - output will be filename of copied files |
| 46 | +```yaml |
| 47 | +# Task configuration level |
| 48 | +code: |
| 49 | + service: '@CleverAge\FlysystemProcessBundle\Task\FileFetchTask' |
| 50 | + options: |
| 51 | + source_filesystem: 'storage.source' |
| 52 | + destination_filesystem: 'storage.destination' |
| 53 | + file_pattern: '/.csv$/' |
| 54 | + remove_source: true |
| 55 | +``` |
| 56 | +
|
| 57 | +* Simple fetch process configuration to cipy a specific file from --input option via <br> ```bin/console cleverage:process:execute my_custom_process --input=foobar.csv -vv``` |
| 58 | + - See config/packages/flysystem.yaml to see configured flysystems/storages. |
| 59 | + - copy input file from 'storage.source' to 'storage.destination' |
| 60 | + - remove .csv from 'storage.source' after copy |
| 61 | + - output will be filename of copied file |
| 62 | +```yaml |
| 63 | +# Full process configuration to use input as filename with the following call |
| 64 | +my_custom_process: |
| 65 | + entry_point: copy_from_input |
| 66 | + tasks: |
| 67 | + copy_from_input: |
| 68 | + service: '@CleverAge\FlysystemProcessBundle\Task\FileFetchTask' |
| 69 | + options: |
| 70 | + source_filesystem: 'storage.source' |
| 71 | + destination_filesystem: 'storage.destination' |
| 72 | + remove_source: true |
| 73 | +``` |
0 commit comments