Documentation
¶
Index ¶
- Constants
- func HandleCreateFile(req protocol.Request, channel protocol.TransportChannel, conf Conf.Config)
- func HandleReadFile(req protocol.Request, channel protocol.TransportChannel, conf Conf.Config)
- func ValidateReadFileParams(params ReadFileParams) error
- type CreateFileErrorResponse
- type CreateFileParams
- type CreateFileRequest
- type CreateFileSuccessResponse
- type File
- type FileNotFoundError
- type GenericError
- type InvalidParamsError
- type MIMEType
- type ReadFileErrorResponse
- type ReadFileParams
- type ReadFileRequest
- type ReadFileSuccessResponse
- type TextFile
Constants ¶
View Source
const ( GenericErrorCode = 100 StatusNotFoundCode = 404 StatusInvalidRequestCode = 400 )
View Source
const ( TEXT_FILE = "text" BINARY_FILE = "binary" IMAGE_FILE = "image" PDF_FILE = "pdf" HTML_FILE = "html" )
Variables ¶
This section is empty.
Functions ¶
func HandleCreateFile ¶
func HandleReadFile ¶
func ValidateReadFileParams ¶
func ValidateReadFileParams(params ReadFileParams) error
Types ¶
type CreateFileErrorResponse ¶
type CreateFileParams ¶
type CreateFileParams struct {
/**
* The name of the file to create
*/
Name string `json:"name"`
/**
* The content of the file
*/
Content string `json:"content"`
/**
* if directories should be created if not present, default is false
*/
CreateDirs bool `json:"create-dirs,omitempty"`
/**
* The permissions of the directory, should be sent as decimal number like 438 (octal 0666).
* Default is 0755, only used if create-dirs is true
*/
CreateDirPermissions int `json:"create-dir-permissions,omitempty"`
/**
* The directory where the file should be created
*/
Dir string `json:"dir,omitempty"`
/**
* The type of the file, e.g. text, image, etc.
* Not always possible to infer from the extension, it might not be present
*/
FileType string `json:"file-type,omitempty"`
/**
* The permissions of the file, should be sent as decimal number like 438 (octal 0666)
*/
Permissions int `json:"permissions,omitempty"`
/**
* If the file should be overwritten if it already exists, default is false
*/
Overwrite bool `json:"overwrite,omitempty"`
}
func NewCreateFileParams ¶
func NewCreateFileParams(params map[string]any, conf Conf.Config) *CreateFileParams
func ValidateCreateRequest ¶
func ValidateCreateRequest(c CreateFileParams, ch protocol.TransportChannel, conf Conf.Config) (bool, CreateFileParams)
type CreateFileRequest ¶
type CreateFileRequest struct {
protocol.Request
Params CreateFileParams `json:"params"`
}
type CreateFileSuccessResponse ¶
func NewCreateFileSuccessResponse ¶
func NewCreateFileSuccessResponse(req protocol.Request, file *File) *CreateFileSuccessResponse
type File ¶
type File struct {
/**
* Name of the file
*/
Name string `json:"name"`
/**
* Absolute path of the parent directory of the file
*/
Dir string `json:"dir"`
/**
* The content of the file
*/
Content string `json:"content"`
/**
* The size of the file in bytes
*/
Size int `json:"size"`
/**
* The type of the file, e.g. text, image, etc.
*/
FileType string `json:"fileType"`
/**
* The version number of this document (it will increase after each
* change, including undo/redo).
*/
Version int `json:"version"`
/**
* The extension of the TextFile
*/
Extension string `json:"extension"`
/**
* A map for storing any additional data
*/
MetaData map[string]any `json:"metaData"`
/**
* The MIME type of the file
*/
MIMEType MIMEType `json:"mimeType"`
/**
* The permissions of the file, e.g. 0777
*/
Permissions int `json:"permissions"`
}
func CreateFile ¶
func CreateFile(params *CreateFileParams) (*File, error)
func NewFileFromCreateFileParams ¶
func NewFileFromCreateFileParams(fileParams *CreateFileParams) *File
func ReadFile ¶
func ReadFile(params *ReadFileParams) (*File, error)
type FileNotFoundError ¶
FileNotFoundError is an error type for file not found
func NewFileNotFoundError ¶
func NewFileNotFoundError(fileName string) *FileNotFoundError
func (*FileNotFoundError) Error ¶
func (e *FileNotFoundError) Error() string
type GenericError ¶
GenericError is an error type for generic errors
func NewGenericError ¶
func NewGenericError() *GenericError
func (*GenericError) Error ¶
func (e *GenericError) Error() string
type InvalidParamsError ¶
InvalidParamsError is an error type for invalid parameters
func NewInvalidParamsError ¶
func NewInvalidParamsError() *InvalidParamsError
func (*InvalidParamsError) Error ¶
func (e *InvalidParamsError) Error() string
type ReadFileErrorResponse ¶
func NewReadFileErrorResponse ¶
func NewReadFileErrorResponse(req protocol.Request, error error) *ReadFileErrorResponse
type ReadFileParams ¶
type ReadFileParams struct {
/**
* The path of the file to read
*/
Name string `json:"path"`
/**
* The path of the parent directory of the file
*/
Dir string `json:"dir"`
/**
* If set to true, reads the file as binary (base64 string), otherwise as text.
* Default is false (read as text)
*/
Binary bool `json:"binary,omitempty"`
/**
* Specifies the maximum number of bytes to read from the file.
* If not set or zero, it is read until the end of the file.
*/
MaxBytes int64 `json:"max-bytes,omitempty"`
/**
* Specifies the offset from where to start reading the file.
* If not set or zero, the file is read from the beginning.
*/
Offset int64 `json:"offset,omitempty"`
/**
* If set to true, checks if the file exists before reading.
* Default is false.
*/
CheckExists bool `json:"check-exists,omitempty"`
}
func NewReadFileParams ¶
func NewReadFileParams(params map[string]any, conf Conf.Config) *ReadFileParams
type ReadFileRequest ¶
type ReadFileRequest struct {
protocol.Request
Params ReadFileParams `json:"params"`
}
type ReadFileSuccessResponse ¶
func NewReadFileSuccessResponse ¶
func NewReadFileSuccessResponse(req protocol.Request, file *File) *ReadFileSuccessResponse
Click to show internal directories.
Click to hide internal directories.