syncFolderToStorage
syncFolderToStorage(
options
):Effect
<[Duration
, [Chunk
<{bucket
:string
;fileName
:string
;localETag
:string
;remoteETag
:null
|string
;uploaded
:boolean
; }>,void
|Chunk
<{bucket
:string
;deleted
:boolean
;fileName
:string
; }>]],Error
|PlatformError
,FileSystem
|Path
|StorageService
>
Defined in: packages/core/src/utils.ts:435
Synchronizes a local folder with cloud storage buckets. This function uploads changed files and optionally deletes orphaned files to keep the storage buckets in sync with the local folder structure.
Parameters
Section titled “Parameters”options
Section titled “options”Configuration object for the sync operation
bucketsToClean?
Section titled “bucketsToClean?”string
[] = []
Array of bucket names to clean of orphaned files (default: [])
concurrency?
Section titled “concurrency?”number
= 1
Number of concurrent operations to run (default: 1)
deleteOrphaned?
Section titled “deleteOrphaned?”boolean
= false
Whether to delete files that exist in storage but not locally (default: false)
folderPath
Section titled “folderPath”string
The local folder path to synchronize
getBucket
Section titled “getBucket”(fileName
) => Effect
<string
, Error
>
Function that determines which bucket a file should be uploaded to based on filename
Returns
Section titled “Returns”Effect
<[Duration
, [Chunk
<{ bucket
: string
; fileName
: string
; localETag
: string
; remoteETag
: null
| string
; uploaded
: boolean
; }>, void
| Chunk
<{ bucket
: string
; deleted
: boolean
; fileName
: string
; }>]], Error
| PlatformError
, FileSystem
| Path
| StorageService
>
An Effect that succeeds with sync results and timing information, or fails with an Error
Example
Section titled “Example”const syncResult = yield* syncFolderToStorage({ folderPath: "/path/to/local/folder", getBucket: (fileName) => Effect.succeed(fileName.endsWith('.js') ? 'js-bucket' : 'other-bucket'), bucketsToClean: ['js-bucket', 'other-bucket'], concurrency: 3, deleteOrphaned: true});