Skip to main content

Working With File History

This guide describes methods for working with file history records.

File history operations#

This chapter describes methods for receiving history records.

Initialization#

import CLFiles from '@cloudike/web_files';
let filesApp;
const options = {  logLevel: 'error' // 'trace' | 'debug' | 'info' | 'warn' | 'error'};
const config = {  authToken: '', // user auth token optional  baseUrl: '', // api base url required  userAgent: '', // user agent name required  wsConfig: { //    sockjs: '', // sockjs url optional    sockjs_for_shares: "", // sockjs for shares url optional      websocket_event_groups: [      "fs",      "photos",      "family"    ], // websocket event groups optional, there are three groups: fs, photos, family    jwt_token: '', // jwt token optional    share_id: '', // share id optional    auth_by_first_message: true // auth by first message optional  }}
try {  filesApp = CLFiles.init(options, config);} catch (error) {  console.log('error', error);}

Get file history#

The following code example demonstrates how to get history records.

const params: IGetHistoryRecordsSchema = {};const opts: CustomRequestConfig = { signal: '<AbortSignal>' };filesApp.fsHistoryService  .getHistoryRecords(params, opts)  .then(({ data }) => {    console.log(data); // IHistoryRecordsSchema  })  .catch((error) => {});

The following code example demonstrates how to get a history record.

const recordId: string = '<recordId>';const opts: CustomRequestConfig = { signal: '<AbortSignal>' };filesApp.fsHistoryService  .getHistoryRecord(recordId, opts)  .then(({ data }) => {    console.log(data); // IHistoryRecordSchema  })  .catch((error) => {});

The following code example demonstrates how to get the last record by node ID.

const nodeId: string = '<nodeId>';const createdGt: string = '<createdGt>';const opts: CustomRequestConfig = { signal: '<AbortSignal>' };filesApp.fsHistoryService  .getLastRecordByNodeId(nodeId, createdGt, opts)  .then((record) => {    console.log(record); // IHistoryRecordSchema})  })  .catch((error) => {});