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
- Variables
- func AddBulkNotSynchronizedOn(c echo.Context) error
- func AddNotSynchronizedOn(c echo.Context) error
- func AddReferencedHandler(c echo.Context) error
- func AddReferencesHandler(c echo.Context) error
- func ArchiveDownloadCreateHandler(c echo.Context) error
- func ArchiveDownloadHandler(c echo.Context) error
- func ChangesFeed(c echo.Context, inst *instance.Instance, sharedDir *vfs.DirDoc) error
- func ChangesFeedForFiles(c echo.Context) error
- func CheckIfMatch(c echo.Context, rev string) error
- func ClearOldVersions(c echo.Context) error
- func ClearTrashHandler(c echo.Context) error
- func CopyFile(c echo.Context, inst *instance.Instance, sharedDrive *sharing.Sharing) error
- func CopyVersionHandler(c echo.Context) error
- func CozyMetadataFromClaims(c echo.Context, setUploadFields bool) (*vfs.FilesCozyMetadata, string)
- func Create(c echo.Context, sharedDrive *sharing.Sharing) error
- func CreationHandler(c echo.Context) error
- func DeleteFileVersionMetadata(c echo.Context) error
- func DestroyFileHandler(c echo.Context) error
- func DirData(c echo.Context, statusCode int, doc *vfs.DirDoc, sharedDrive *sharing.Sharing) error
- func FileCopyHandler(c echo.Context) error
- func FileData(c echo.Context, statusCode int, doc *vfs.FileDoc, withVersions bool, ...) error
- func FileDocFromReq(c echo.Context, name, dirID string) (*vfs.FileDoc, error)
- func FileDownload(c echo.Context, sharedDrive *sharing.Sharing) error
- func FileDownloadCreateHandler(c echo.Context) error
- func FileDownloadHandler(c echo.Context) error
- func FindFilesMango(c echo.Context) error
- func GetAllDocs(c echo.Context) error
- func GetChildrenHandler(c echo.Context) error
- func GetDirSize(c echo.Context) error
- func HeadDirOrFile(c echo.Context) error
- func IconHandler(c echo.Context) error
- func ListNotSynchronizedOn(c echo.Context) error
- func ListReferencesHandler(c echo.Context) error
- func ModifyFileVersionMetadata(c echo.Context) error
- func ModifyMetadataByIDHandler(c echo.Context) error
- func ModifyMetadataByIDInBatchHandler(c echo.Context) error
- func ModifyMetadataByPathHandler(c echo.Context) error
- func NewDir(doc *vfs.DirDoc, sharedDrive *sharing.Sharing) *dir
- func NewFile(doc *vfs.FileDoc, i *instance.Instance, sharedDrive *sharing.Sharing) *file
- func NewNoteImage(inst *instance.Instance, img *note.Image) *apiNoteImage
- func NotSynchronizedOnRoutes(router *echo.Group)
- func OverwriteFileContent(c echo.Context, sharedDrive *sharing.Sharing) error
- func OverwriteFileContentHandler(c echo.Context) error
- func PreviewHandler(c echo.Context) error
- func ReadFileContentFromIDHandler(c echo.Context) error
- func ReadFileContentFromPathHandler(c echo.Context) error
- func ReadFileContentFromSharingFileID(c echo.Context, fileID string) error
- func ReadFileContentFromVersion(c echo.Context) error
- func ReadMetadataFromIDHandler(c echo.Context) error
- func ReadMetadataFromPath(c echo.Context, sharedDrive *sharing.Sharing) error
- func ReadMetadataFromPathHandler(c echo.Context) error
- func ReadTrashFilesHandler(c echo.Context) error
- func ReferencesRoutes(router *echo.Group)
- func RemoveBulkNotSynchronizedOn(c echo.Context) error
- func RemoveNotSynchronizedOn(c echo.Context) error
- func RemoveReferencedHandler(c echo.Context) error
- func RemoveReferencesHandler(c echo.Context) error
- func Restore(c echo.Context, sharedDrive *sharing.Sharing) error
- func RestoreTrashFileHandler(c echo.Context) error
- func RevertFileVersion(c echo.Context) error
- func Routes(router *echo.Group)
- func SendFileFromDoc(instance *instance.Instance, c echo.Context, doc *vfs.FileDoc, ...) error
- func SharedDrivesCreationHandler(c echo.Context) error
- func ThumbnailHandler(c echo.Context) error
- func Trash(c echo.Context, sharedDrive *sharing.Sharing) error
- func TrashHandler(c echo.Context) error
- func UpdateDirCozyMetadata(c echo.Context, dir *vfs.DirDoc)
- func UpdateFileCozyMetadata(c echo.Context, file *vfs.FileDoc, setUploadFields bool)
- func UploadMetadataHandler(c echo.Context) error
- func WrapVfsError(err error) error
- type ApiDiskSize
- func (d *ApiDiskSize) Clone() couchdb.Doc
- func (d *ApiDiskSize) DocType() string
- func (d *ApiDiskSize) ID() string
- func (d *ApiDiskSize) Included() []jsonapi.Object
- func (d *ApiDiskSize) Links() *jsonapi.LinksList
- func (d *ApiDiskSize) Relationships() jsonapi.RelationshipMap
- func (d *ApiDiskSize) Rev() string
- func (d *ApiDiskSize) SetID(id string)
- func (d *ApiDiskSize) SetRev(_ string)
Constants ¶
const TagSeparator = ","
TagSeparator is the character separating tags
Variables ¶
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 ¶
ChangesFeed is the handler for GET /files/_changes, and indirectly, GET /sharings/drives/:sharingID/_changes. It is similar to the changes feed of CouchDB with some additional options, like skip_trashed.
sharedDir is an optional directory used to filter the changes feed. It is used when the changes feed is called from a sharing drive. The changes feed will only return files that are below this directory. If missing, no special filtering is done, everything is returned. Otherwise, options like `include_file_path` and `include_docs` are forced to true. if sharedDir is present, it is the responsibility of the caller to check for the right permissions (anything outside this directory should only be deletions with the document ID as only information)
func ChangesFeedForFiles ¶
func ChangesFeedForFiles(c echo.Context) error
func CheckIfMatch ¶
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 CopyFile ¶
Copy a single file from an instance to itself using parameters from the echo Context: - url param: `file-id`: surce file's ID - url query param: `DirID`: optional destination folder's ID - url query param: `Name`: optional destination file name
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 Create ¶
Create 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 CreationHandler ¶
func CreationHandler(c echo.Context) error
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 FileCopyHandler ¶
func FileCopyHandler(c echo.Context) error
FileCopyHandler handles POST requests on /files/:file-id/copy
It is used to duplicate the given file and its metadata except for relationships.
func FileData ¶
func FileData(c echo.Context, statusCode int, doc *vfs.FileDoc, withVersions bool, links *jsonapi.LinksList, sharedDrive *sharing.Sharing) error
FileData returns a jsonapi representation of the given file.
func FileDocFromReq ¶
FileDocFromReq creates a FileDoc from an incoming request.
func FileDownload ¶
FileDownload stores the required path into a secret usable for download handler below.
func FileDownloadCreateHandler ¶
func FileDownloadCreateHandler(c echo.Context) error
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 GetAllDocs ¶
func GetAllDocs(c echo.Context) error
GetAllDocs is the handler for POST /files/_all_docs
func GetChildrenHandler ¶
func GetChildrenHandler(c echo.Context) error
GetChildrenHandler returns a list of children of a folder
func GetDirSize ¶
func GetDirSize(c echo.Context) error
GetDirSize returns the size of a directory (the sum of the size of the files in this directory, including those in subdirectories).
func HeadDirOrFile ¶
func HeadDirOrFile(c echo.Context) error
HeadDirOrFile handles HEAD requests on directory or file to check their existence
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 NewNoteImage ¶
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 OverwriteFileContent ¶
OverwriteFileContent handles PUT requests on /files/:file-id to overwrite the content of a file given its identifier.
func OverwriteFileContentHandler ¶
func OverwriteFileContentHandler(c echo.Context) error
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. TODO: use SendFileFromDoc?
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 ReadMetadataFromPath ¶
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 Restore ¶
Restore handle POST requests on /files/trash/file-id and can be used to restore a file or directory from the trash.
func RestoreTrashFileHandler ¶
func RestoreTrashFileHandler(c echo.Context) error
func RevertFileVersion ¶
func RevertFileVersion(c echo.Context) error
RevertFileVersion restores an old version of the file content.
func SendFileFromDoc ¶
func SendFileFromDoc(instance *instance.Instance, c echo.Context, doc *vfs.FileDoc, checkPermission bool) error
SendFileFromDoc sends the file content to the client. It does permissions, inlining, CSP rules, and PDF single page serving
func SharedDrivesCreationHandler ¶
func SharedDrivesCreationHandler(c echo.Context) error
SharedDrivesCreationHandler is the handler for POST /files/drives. It creates the directory where shared and external drives are saved if it doesn't exist, and return information about this directory.
func ThumbnailHandler ¶
func ThumbnailHandler(c echo.Context) error
ThumbnailHandler serves thumbnails of the images/photos
func Trash ¶
Trash handles all DELETE requests on /files/:file-id and moves the file or directory with the specified file-id to the trash.
func TrashHandler ¶
func TrashHandler(c echo.Context) error
func UpdateDirCozyMetadata ¶
func UpdateFileCozyMetadata ¶
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 ¶
WrapVfsError returns a formatted error from a golang error emitted by the vfs
Types ¶
type ApiDiskSize ¶
func (*ApiDiskSize) Clone ¶
func (d *ApiDiskSize) Clone() couchdb.Doc
func (*ApiDiskSize) DocType ¶
func (d *ApiDiskSize) DocType() string
func (*ApiDiskSize) ID ¶
func (d *ApiDiskSize) ID() string
func (*ApiDiskSize) Included ¶
func (d *ApiDiskSize) Included() []jsonapi.Object
func (*ApiDiskSize) Links ¶
func (d *ApiDiskSize) Links() *jsonapi.LinksList
func (*ApiDiskSize) Relationships ¶
func (d *ApiDiskSize) Relationships() jsonapi.RelationshipMap
func (*ApiDiskSize) Rev ¶
func (d *ApiDiskSize) Rev() string
func (*ApiDiskSize) SetID ¶
func (d *ApiDiskSize) SetID(id string)
func (*ApiDiskSize) SetRev ¶
func (d *ApiDiskSize) SetRev(_ string)