You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// @ts-ignore Argument of type 'string | false' is not assignable to parameter of type 'string'. Type 'boolean' is not assignable to type 'string'.ts(2345)
219
-
pathsList.push(...entriesPathList)
219
+
// construct an Array with all the paths to ensure the existence of
// @ts-ignore Argument of type 'string | false' is not assignable to parameter of type 'string'. Type 'boolean' is not assignable to type 'string'.ts(2345)
Saves the files given in the fileurl attribute of each entries
499
499
500
500
You need the full permission on `io.cozy.files` in your manifest to use this function.
@@ -513,6 +513,9 @@ You need the full permission on `io.cozy.files` in your manifest to use this fun
513
513
| entries.shouldReplaceFile | <code>function</code> | use this function to state if the current entry should be forced to be redownloaded and replaced. Usefull if we know the file content can change and we always want the last version. |
514
514
| entries.fileAttributes | <code>object</code> | ex: `{created_at: new Date()}` sets some additionnal file attributes passed to cozyClient.file.create |
515
515
| entries.subPath | <code>string</code> | A subpath to save all files, will be created if needed. |
516
+
| entries.contract | <code>object</code> | contract object associated to the files |
517
+
| entries.contract.id | <code>string</code> | id of the contract |
518
+
| entries.contract.name | <code>string</code> | name of the contract |
516
519
| fields | <code>object</code> | is the argument given to the main function of your connector by the BaseKonnector. It especially contains a `folderPath` which is the string path configured by the user in collect/home |
517
520
| options | <code>object</code> | global options |
518
521
| options.timeout | <code>number</code> | timestamp which can be used if your connector needs to fetch a lot of files and if the stack does not give enough time to your connector to fetch it all. It could happen that the connector is stopped right in the middle of the download of the file and the file will be broken. With the `timeout` option, the `saveFiles` function will check if the timeout has passed right after downloading each file and then will be sure to be stopped cleanly if the timeout is not too long. And since it is really fast to check that a file has already been downloaded, on the next run of the connector, it will be able to download some more files, and so on. If you want the timeout to be in 10s, do `Date.now() + 10*1000`. You can try it in the previous code. |
@@ -522,6 +525,9 @@ You need the full permission on `io.cozy.files` in your manifest to use this fun
522
525
| options.validateFileContent | <code>boolean</code> \| <code>function</code> | default false. Also check the content of the file to recognize the mime type |
523
526
| options.fileIdAttributes | <code>Array</code> | array of strings : Describes which attributes of files will be taken as primary key for files to check if they already exist, even if they are moved. If not given, the file path will used for deduplication as before. |
524
527
| options.subPath | <code>string</code> | A subpath to save this file, will be created if needed. |
528
+
|[contract]| <code>object</code> | contract object associated to the file |
529
+
|[contract.id]| <code>string</code> | id of the contract |
530
+
|[contract.name]| <code>string</code> | name of the contract |
525
531
| options.fetchFile | <code>function</code> | the connector can give it's own function to fetch the file from the website, which will be run only when necessary (if the corresponding file is missing on the cozy) function returning the stream). This function must return a promise resolved as a stream |
526
532
| options.verboseFilesLog | <code>boolean</code> | the connector will send saveFiles result as a warning |
* @param {Function} entries.shouldReplaceFile - use this function to state if the current entry should be forced to be redownloaded and replaced. Usefull if we know the file content can change and we always want the last version.
51
51
* @param {object} entries.fileAttributes - ex: `{created_at: new Date()}` sets some additionnal file attributes passed to cozyClient.file.create
52
52
* @param {string} entries.subPath - A subpath to save all files, will be created if needed.
53
+
* @param {object} entries.contract - contract object associated to the files
54
+
* @param {string} entries.contract.id - id of the contract
55
+
* @param {string} entries.contract.name - name of the contract
53
56
* @param {object} fields - is the argument given to the main function of your connector by the BaseKonnector. It especially contains a `folderPath` which is the string path configured by the user in collect/home
54
57
* @param {object} options - global options
55
58
* @param {number} options.timeout - timestamp which can be used if your connector needs to fetch a lot of files and if the stack does not give enough time to your connector to fetch it all. It could happen that the connector is stopped right in the middle of the download of the file and the file will be broken. With the `timeout` option, the `saveFiles` function will check if the timeout has passed right after downloading each file and then will be sure to be stopped cleanly if the timeout is not too long. And since it is really fast to check that a file has already been downloaded, on the next run of the connector, it will be able to download some more files, and so on. If you want the timeout to be in 10s, do `Date.now() + 10*1000`. You can try it in the previous code.
* @param {boolean|Function} options.validateFileContent - default false. Also check the content of the file to recognize the mime type
60
63
* @param {Array} options.fileIdAttributes - array of strings : Describes which attributes of files will be taken as primary key for files to check if they already exist, even if they are moved. If not given, the file path will used for deduplication as before.
61
64
* @param {string} options.subPath - A subpath to save this file, will be created if needed.
65
+
* @param {object} [contract] - contract object associated to the file
66
+
* @param {string} [contract.id] - id of the contract
67
+
* @param {string} [contract.name] - name of the contract
68
+
62
69
* @param {Function} options.fetchFile - the connector can give it's own function to fetch the file from the website, which will be run only when necessary (if the corresponding file is missing on the cozy) function returning the stream). This function must return a promise resolved as a stream
63
70
* @param {boolean} options.verboseFilesLog - the connector will send saveFiles result as a warning
0 commit comments