files

package
v0.0.0-...-4b98c26 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 7, 2021 License: AGPL-3.0 Imports: 34 Imported by: 0

Documentation

Overview

Package files is the HTTP frontend of the vfs package. It exposes an HTTP api to manipulate the filesystem and offer all the possibilities given by the vfs.

Index

Constants

View Source
const TagSeparator = ","

TagSeparator is the character separating tags

Variables

View Source
var ErrDocTypeInvalid = errors.New("Invalid document type")

ErrDocTypeInvalid is used when the document type sent is not recognized

Functions

func AddBulkNotSynchronizedOn

func AddBulkNotSynchronizedOn(c echo.Context) error

AddBulkNotSynchronizedOn add some not_synchronized_on for a device POST /data/:type/:id/relationships/not_synchronizing Beware, this is actually used in the web/data Routes

func AddNotSynchronizedOn

func AddNotSynchronizedOn(c echo.Context) error

AddNotSynchronizedOn is the echo.handler for adding not_synchronized_on to a directory POST /files/:file-id/relationships/not_synchronized_on

func AddReferencedHandler

func AddReferencedHandler(c echo.Context) error

AddReferencedHandler is the echo.handler for adding referenced_by to a file POST /files/:file-id/relationships/referenced_by

func AddReferencesHandler

func AddReferencesHandler(c echo.Context) error

AddReferencesHandler add some files references to a doc POST /data/:type/:id/relationships/references Beware, this is actually used in the web/data Routes

func ArchiveDownloadCreateHandler

func ArchiveDownloadCreateHandler(c echo.Context) error

ArchiveDownloadCreateHandler handles requests to /files/archive and stores the paremeters with a secret to be used in download handler below.s

func ArchiveDownloadHandler

func ArchiveDownloadHandler(c echo.Context) error

ArchiveDownloadHandler handles requests to /files/archive/:secret/whatever.zip and creates on the fly zip archive from the parameters linked to secret.

func ChangesFeed

func ChangesFeed(c echo.Context) error

ChangesFeed is the handler for GET /files/_changes. It is similar to the changes feed of CouchDB with some additional options, like skip_trashed.

func CheckIfMatch

func CheckIfMatch(c echo.Context, rev string) error

CheckIfMatch checks if the revision provided matches the revision number given in the request, in the header and/or the query.

func ClearOldVersions

func ClearOldVersions(c echo.Context) error

ClearOldVersions is the handler for DELETE /files/versions. It deletes all the old versions of all files to make space for new files.

func ClearTrashHandler

func ClearTrashHandler(c echo.Context) error

ClearTrashHandler handles DELETE request to clear the trash

func CopyVersionHandler

func CopyVersionHandler(c echo.Context) error

CopyVersionHandler handles POST requests on /files/:file-id/versions.

It can be used to create a new version of a file, with the same content but new metadata.

func CozyMetadataFromClaims

func CozyMetadataFromClaims(c echo.Context, setUploadFields bool) (*vfs.FilesCozyMetadata, string)

CozyMetadataFromClaims returns a FilesCozyMetadata struct, with the app fields filled with information from the permission claims.

func CreationHandler

func CreationHandler(c echo.Context) error

CreationHandler handle all POST requests on /files/:file-id aiming at creating a new document in the FS. Given the Type parameter of the request, it will either upload a new file or create a new directory.

func DeleteFileVersionMetadata

func DeleteFileVersionMetadata(c echo.Context) error

DeleteFileVersionMetadata handles DELETE requests on /files/:file-id/:version-id

It can be used to delete an old version of a file.

func DestroyFileHandler

func DestroyFileHandler(c echo.Context) error

DestroyFileHandler handles DELETE request to clear one element from the trash

func FileData

func FileData(c echo.Context, statusCode int, doc *vfs.FileDoc, withVersions bool, links *jsonapi.LinksList) error

FileData returns a jsonapi representation of the given file.

func FileDocFromReq

func FileDocFromReq(c echo.Context, name, dirID string) (*vfs.FileDoc, error)

FileDocFromReq creates a FileDoc from an incoming request.

func FileDownloadCreateHandler

func FileDownloadCreateHandler(c echo.Context) error

FileDownloadCreateHandler stores the required path into a secret usable for download handler below.

func FileDownloadHandler

func FileDownloadHandler(c echo.Context) error

FileDownloadHandler send a file that have previously be defined through FileDownloadCreateHandler

func FindFilesMango

func FindFilesMango(c echo.Context) error

FindFilesMango is the route POST /files/_find used to retrieve files and their metadata from a mango query.

func GetChildrenHandler

func GetChildrenHandler(c echo.Context) error

GetChildrenHandler returns a list of children of a folder

func HeadDirOrFile

func HeadDirOrFile(c echo.Context) error

HeadDirOrFile handles HEAD requests on directory or file to check their existence

func IconHandler

func IconHandler(c echo.Context) error

IconHandler serves icon for the PDFs.

func ListNotSynchronizedOn

func ListNotSynchronizedOn(c echo.Context) error

ListNotSynchronizedOn list all directories not synchronized on a device GET /data/:type/:id/relationships/not_synchronizing Beware, this is actually used in the web/data Routes

func ListReferencesHandler

func ListReferencesHandler(c echo.Context) error

ListReferencesHandler list all files referenced by a doc GET /data/:type/:id/relationships/references Beware, this is actually used in the web/data Routes

func ModifyFileVersionMetadata

func ModifyFileVersionMetadata(c echo.Context) error

ModifyFileVersionMetadata handles PATCH requests on /files/:file-id/:version-id

It can be used to modify tags on an old version of a file.

func ModifyMetadataByIDHandler

func ModifyMetadataByIDHandler(c echo.Context) error

ModifyMetadataByIDHandler handles PATCH requests on /files/:file-id

It can be used to modify the file or directory metadata, as well as moving and renaming it in the filesystem.

func ModifyMetadataByIDInBatchHandler

func ModifyMetadataByIDInBatchHandler(c echo.Context) error

ModifyMetadataByIDInBatchHandler handles PATCH requests on /files/.

It can be used to modify many files or directories metadata, as well as moving and renaming it in the filesystem, in batch.

func ModifyMetadataByPathHandler

func ModifyMetadataByPathHandler(c echo.Context) error

ModifyMetadataByPathHandler handles PATCH requests on /files/metadata

It can be used to modify the file or directory metadata, as well as moving and renaming it in the filesystem.

func NewFile

func NewFile(doc *vfs.FileDoc, i *instance.Instance) *file

NewFile creates an instance of file struct from a vfs.FileDoc document.

func NewNoteImage

func NewNoteImage(inst *instance.Instance, img *note.Image) *apiNoteImage

NewNoteImage creates an object that can be used to serialize an image for a note to JSON-API.

func NotSynchronizedOnRoutes

func NotSynchronizedOnRoutes(router *echo.Group)

NotSynchronizedOnRoutes adds the /data/:doctype/:docid/relationships/not_synchronizing routes.

func OverwriteFileContentHandler

func OverwriteFileContentHandler(c echo.Context) error

OverwriteFileContentHandler handles PUT requests on /files/:file-id to overwrite the content of a file given its identifier.

func PreviewHandler

func PreviewHandler(c echo.Context) error

PreviewHandler serves preview images for the PDFs.

func ReadFileContentFromIDHandler

func ReadFileContentFromIDHandler(c echo.Context) error

ReadFileContentFromIDHandler handles all GET requests on /files/:file-id aiming at downloading a file given its ID. It serves the file in inline mode.

func ReadFileContentFromPathHandler

func ReadFileContentFromPathHandler(c echo.Context) error

ReadFileContentFromPathHandler handles all GET request on /files/download aiming at downloading a file given its path. It serves the file in in attachment mode.

func ReadFileContentFromVersion

func ReadFileContentFromVersion(c echo.Context) error

ReadFileContentFromVersion handles the download of an old version of the file content.

func ReadMetadataFromIDHandler

func ReadMetadataFromIDHandler(c echo.Context) error

ReadMetadataFromIDHandler handles all GET requests on /files/:file- id aiming at getting file metadata from its id.

func ReadMetadataFromPathHandler

func ReadMetadataFromPathHandler(c echo.Context) error

ReadMetadataFromPathHandler handles all GET requests on /files/metadata aiming at getting file metadata from its path.

func ReadTrashFilesHandler

func ReadTrashFilesHandler(c echo.Context) error

ReadTrashFilesHandler handle GET requests on /files/trash and return the list of trashed files and directories

func ReferencesRoutes

func ReferencesRoutes(router *echo.Group)

ReferencesRoutes adds the /data/:doctype/:docid/relationships/references routes.

func RemoveBulkNotSynchronizedOn

func RemoveBulkNotSynchronizedOn(c echo.Context) error

RemoveBulkNotSynchronizedOn removes some not_synchronized_on for several directories. DELETE /data/:type/:id/relationships/not_synchronizing Beware, this is actually used in the web/data Routes

func RemoveNotSynchronizedOn

func RemoveNotSynchronizedOn(c echo.Context) error

RemoveNotSynchronizedOn is the echo.handler for removing not_synchronized_on to a directory DELETE /files/:file-id/relationships/not_synchronized_on

func RemoveReferencedHandler

func RemoveReferencedHandler(c echo.Context) error

RemoveReferencedHandler is the echo.handler for removing referenced_by to a file DELETE /files/:file-id/relationships/referenced_by

func RemoveReferencesHandler

func RemoveReferencesHandler(c echo.Context) error

RemoveReferencesHandler remove some files references from a doc DELETE /data/:type/:id/relationships/references Beware, this is actually used in the web/data Routes

func RestoreTrashFileHandler

func RestoreTrashFileHandler(c echo.Context) error

RestoreTrashFileHandler handle POST requests on /files/trash/file-id and can be used to restore a file or directory from the trash.

func RevertFileVersion

func RevertFileVersion(c echo.Context) error

RevertFileVersion restores an old version of the file content.

func Routes

func Routes(router *echo.Group)

Routes sets the routing for the files service

func ThumbnailHandler

func ThumbnailHandler(c echo.Context) error

ThumbnailHandler serves thumbnails of the images/photos

func TrashHandler

func TrashHandler(c echo.Context) error

TrashHandler handles all DELETE requests on /files/:file-id and moves the file or directory with the specified file-id to the trash.

func UploadMetadataHandler

func UploadMetadataHandler(c echo.Context) error

UploadMetadataHandler accepts a metadata objet and persist it, so that it can be used in a future file upload.

func WrapVfsError

func WrapVfsError(err error) error

WrapVfsError returns a formatted error from a golang error emitted by the vfs

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL