UNPKG

ithit.webdav.server

Version:

With IT Hit WebDAV Server Engine for Node.js you can create your own WebDAV server, add WebDAV support to your existing Node.js project or DAV-enable your CMS/DMS/CRM.

57 lines (56 loc) 3.12 kB
/// <reference types="node" /> import { IncomingMessage, ServerResponse } from "http"; /** * @copyright Copyright (c) 2017 IT Hit. All rights reserved. */ /** * Base interface for items that have content, like {@link IFile}. */ export interface IContent { /** * Gets the media type of the file. * The mime-type provided by this property is returned in a Content-Type header with GET request. * When deciding which action to perform when downloading a file some WebDAV clients and browsers * (such as Internet Explorer) rely on file extension, while others (such as Firefox) rely on Content-Type * header returned by server. For identical behavior in all browsers and WebDAV clients your server must * return a correct mime-type with a requested file. */ readonly contentType: string; /** * Gets the size of the file content in bytes. */ readonly contentLength: number; /** * Gets entity tag - string that identifies current state of resource's content. * More information about etags is available here: http://en.wikipedia.org/wiki/HTTP_ETag * You can return here either cheksum or hash or counter which increases with every modification. * This property shall return different value if content changes. */ readonly etag: string; /** * Reads the file content from the repository and writes it to the specified stream. * Client application can request only a part of a file specifying Range header. Download managers * may use this header to download single file using several threads at a time. * @param output Output stream. * @param startIndex The zero-bazed byte offset in file content at which to begin copying bytes to * the output stream. * @param count The number of bytes to be written to the output stream. * @exception NeedPrivilegesException The user doesn't have enough privileges. * @exception DavException In other cases. */ read(output: ServerResponse, startIndex: number, count: number): Promise<void>; /** * Saves the content of the file from the specified stream to the WebDAV repository. * @param content Stream to read the content of the file from. * @param contentType Indicates the media type of the file. * @param startIndex Start offset to which content shall be saved. * @param totalFileSize Entire length of the file. Is is not less then length of content stream. * @returns Boolean value indicating whether entire stream was written. This value is used by engine to take decision whether * autocheckin shall be performed. * @exception LockedException The file was locked and client did not provide lock token. * @exception NeedPrivilegesException The user doesn't have enough privileges. * @exception InsufficientStorageException Quota limit is reached. * @exception DavException In other cases. */ write(content: IncomingMessage, contentType: string, startIndex: number, totalFileSize: number): Promise<boolean>; }