0.1.6 • Published yesterday
@or-sdk/files-sync-node
Licence
Apache-2.0
Version
0.1.6
Deps
6
Size
40 kB
Vulns
0
Weekly
0
FilesSync SDK (for Node.js)
This SDK is designed to be used with Node.js only.
Installation
npm i @or-sdk/files-sync-node
Usage
import { FilesSyncNode } from '@or-sdk/files-sync-node'
// with direct api url
const files = new FilesSyncNode({
token: 'my-account-token-string',
filesApiUrl: 'https://example.files/endpoint'
});
// with service discovery (slower)
const files = new FilesSyncNode({
token: 'my-account-token-string',
discoveryUrl: 'https://example.discovery/endpoint'
});
Push local directory to remote Files directory
Push local directory ./my-data (could be relative or absolute path) into remote directory sync-local
// create sdk instance
import { FilesSyncNode } from '@or-sdk/files-sync-node'
const client = new FilesSyncNode({...})
// push directory
await client.pushLocalPathToFiles('./my-data', 'sync-local')
// set uploaded files as public
await client.pushLocalPathToFiles('./my-data', 'sync-local', {
isPublic: true,
})
// set uploaded to expire in 1 hour
await client.pushLocalPathToFiles('./my-data', 'sync-local', {
ttl: Date.now() + 3_600_000,
})
Debugging
To see debug logs of synching define environment variable DEBUG with value files-sync:
DEBUG='files-sync' node ./run_logic.js