File Comments

A FileComment is a comment attached to a file by a user.

List File Comments by Path

SDK Method

FileComment.listFor()

Return Object

FileComment[]

Authorization Requirement

Available to all authenticated keys or sessions.

Method Arguments

ArgumentDescription
path
string
Required
Path to operate on.

Additional Arguments

Example Request

import FileComment from 'files.com/lib/models/FileComment';
import * as FilesErrors from 'files.com/lib/Errors';

try {
  const fileComments = await FileComment.listFor(path);
  for (const fileComment of fileComments) {
    // Operate on fileComment
  }
} catch (err) {
  if (err instanceof FilesErrors.NotAuthenticatedError) {
    console.error(`Authentication Error Occurred (${err.constructor.name}): ${err.error}`);
  } else if (err instanceof FilesErrors.FilesError) {
    console.error(`Unknown Error Occurred (${err.constructor.name}): ${err.error}`);
  } else {
    throw err;
  }
}

Create File Comment

SDK Method

FileComment.create()

Return Object

FileComment

Authorization Requirement

Available to all authenticated keys or sessions.

Method Arguments

ArgumentDescription
body
string
Required
Comment body.
path
string
Required
File path.

Example Request

import FileComment from 'files.com/lib/models/FileComment';
import * as FilesErrors from 'files.com/lib/Errors';

try {
  const fileComment = await FileComment.create({
    body: "What a great file!",
    path: "path",
  });
  // Operate on fileComment
} catch (err) {
  if (err instanceof FilesErrors.NotAuthenticatedError) {
    console.error(`Authentication Error Occurred (${err.constructor.name}): ${err.error}`);
  } else if (err instanceof FilesErrors.FilesError) {
    console.error(`Unknown Error Occurred (${err.constructor.name}): ${err.error}`);
  } else {
    throw err;
  }
}

Update File Comment

SDK Method

fileComment.update()

Return Object

FileComment

Authorization Requirement

Available to all authenticated keys or sessions.

Method Arguments

ArgumentDescription
body
string
Required
Comment body.

Example Request

import FileComment from 'files.com/lib/models/FileComment';
import * as FilesErrors from 'files.com/lib/Errors';

try {
  const fileComment = (await FileComment.list())[0];
  await fileComment.update({
    body: "What a great file!",
  });
} catch (err) {
  if (err instanceof FilesErrors.NotAuthenticatedError) {
    console.error(`Authentication Error Occurred (${err.constructor.name}): ${err.error}`);
  } else if (err instanceof FilesErrors.FilesError) {
    console.error(`Unknown Error Occurred (${err.constructor.name}): ${err.error}`);
  } else {
    throw err;
  }
}

Delete File Comment

SDK Method

fileComment.delete()

Return Object

No return value.

Authorization Requirement

Available to all authenticated keys or sessions.

Example Request

import FileComment from 'files.com/lib/models/FileComment';
import * as FilesErrors from 'files.com/lib/Errors';

try {
  const fileComment = (await FileComment.list())[0];
  await fileComment.delete();
} catch (err) {
  if (err instanceof FilesErrors.NotAuthenticatedError) {
    console.error(`Authentication Error Occurred (${err.constructor.name}): ${err.error}`);
  } else if (err instanceof FilesErrors.FilesError) {
    console.error(`Unknown Error Occurred (${err.constructor.name}): ${err.error}`);
  } else {
    throw err;
  }
}

The FileComment Object

Some of the methods above return a FileComment object. The attributes of this object are listed below.

AttributeDescription
id
int64
File Comment ID
body
string
Comment body.
reactions
array(object)
Reactions to this comment.