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.

FileCommentListForParams Fields

FieldDescription
Path
string
Required
Path to operate on.

Additional Arguments

Example Request

import (
    "fmt"
    "errors"

    files_sdk "github.com/Files-com/files-sdk-go/v3"
    file_comment "github.com/Files-com/files-sdk-go/v3/filecomment"
)

fileCommentIterator, err := file_comment.ListFor(files_sdk.FileCommentListForParams{Path: "path"})
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Println("Response Error Occurred (" + respErr.Type + "): " + respErr.ErrorMessage)
    } else {
        fmt.Printf("Unexpected Error: %s\n", err.Error())
    }
}

for fileCommentIterator.Next() {
    fileComment := fileCommentIterator.fileComment()
}
err = fileCommentIterator.Err()
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Println("Response Error Occurred (" + respErr.Type + "): " + respErr.ErrorMessage)
    } else {
        fmt.Printf("Unexpected Error: %s\n", err.Error())
    }
}

Create File Comment

SDK Method

filecomment.Create()

Return Object

FileComment

Authorization Requirement

Available to all authenticated keys or sessions.

FileCommentCreateParams Fields

FieldDescription
Body
string
Required
Comment body.
Path
string
Required
File path.

Example Request

import (
    "fmt"
    "errors"

    files_sdk "github.com/Files-com/files-sdk-go/v3"
    file_comment "github.com/Files-com/files-sdk-go/v3/filecomment"
)

fileComment, err := file_comment.Create(files_sdk.FileCommentCreateParams{
  Body: "What a great file!",
  Path: "path"
})
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Println("Response Error Occurred (" + respErr.Type + "): " + respErr.ErrorMessage)
    } else {
        fmt.Printf("Unexpected Error: %s\n", err.Error())
    }
}

Update File Comment

SDK Method

filecomment.Update()

Return Object

FileComment

Authorization Requirement

Available to all authenticated keys or sessions.

FileCommentUpdateParams Fields

FieldDescription
Id
int64
Required
File Comment ID.
Body
string
Required
Comment body.

Example Request

import (
    "fmt"
    "errors"

    files_sdk "github.com/Files-com/files-sdk-go/v3"
    file_comment "github.com/Files-com/files-sdk-go/v3/filecomment"
)

fileComment, err := file_comment.Update(files_sdk.FileCommentUpdateParams{
  Id: 1,
  Body: "What a great file!"
})
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Println("Response Error Occurred (" + respErr.Type + "): " + respErr.ErrorMessage)
    } else {
        fmt.Printf("Unexpected Error: %s\n", err.Error())
    }
}

Delete File Comment

SDK Method

filecomment.Delete()

Return Object

No return value.

Authorization Requirement

Available to all authenticated keys or sessions.

FileCommentDeleteParams Fields

FieldDescription
Id
int64
Required
File Comment ID.

Example Request

import (
    "fmt"
    "errors"

    files_sdk "github.com/Files-com/files-sdk-go/v3"
    file_comment "github.com/Files-com/files-sdk-go/v3/filecomment"
)

err := file_comment.Delete(files_sdk.FileCommentDeleteParams{Id: 1})
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Println("Response Error Occurred (" + respErr.Type + "): " + respErr.ErrorMessage)
    } else {
        fmt.Printf("Unexpected Error: %s\n", err.Error())
    }
}

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.