File Comments

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

List File Comments by Path

SDK Method

file_comment.ListFor()

Return Values

Returns a *file_comment.Iter and an error. Range over All() to receive files_sdk.FileComment values and errors. Check each loop error before using its resource. Next() and Err() remain supported.

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.Printf("API error (%s): %s\n", respErr.Type, respErr.ErrorMessage)
    } else {
        fmt.Printf("Request failed: %v\n", err)
    }
    return
}

for fileComment, err := range fileCommentIterator.All() {
    if err != nil {
        var respErr files_sdk.ResponseError
        if errors.As(err, &respErr) {
            fmt.Printf("API error (%s): %s\n", respErr.Type, respErr.ErrorMessage)
        } else {
            fmt.Printf("Request failed: %v\n", err)
        }
        return
    }
    fmt.Println(fileComment)
}

Create File Comment

SDK Method

file_comment.Create()

Return Values

Returns a files_sdk.FileComment value and an error.

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.Printf("API error (%s): %s\n", respErr.Type, respErr.ErrorMessage)
    } else {
        fmt.Printf("Request failed: %v\n", err)
    }
    return
}
fmt.Println(fileComment)

Update File Comment

SDK Method

file_comment.Update()

Return Values

Returns a files_sdk.FileComment value and an error.

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.Printf("API error (%s): %s\n", respErr.Type, respErr.ErrorMessage)
    } else {
        fmt.Printf("Request failed: %v\n", err)
    }
    return
}
fmt.Println(fileComment)

Delete File Comment

SDK Method

file_comment.Delete()

Return Values

Returns an error, or nil on success.

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.Printf("API error (%s): %s\n", respErr.Type, respErr.ErrorMessage)
    } else {
        fmt.Printf("Request failed: %v\n", err)
    }
    return
}

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.