UNPKG

2.69 kBTypeScriptView Raw
1/// <reference types="node" />
2import Client from "./client";
3import FileSystemElement from "./fileSystemElement";
4import Folder from "./folder";
5/**
6 * The file class represents a file in nextcloud.
7 * It exposes file properties and content handling, commenting and tagging
8 */
9export default class File implements FileSystemElement {
10 private memento;
11 private client;
12 constructor(client: Client, name: string, baseName: string, lastmod: string, size: number, mime: string, id: number);
13 /**
14 * The name of the file including the path
15 * The name is readonly
16 */
17 get name(): string;
18 /**
19 * The base name of the file (file name without path)
20 * The base name is readonly
21 */
22 get baseName(): string;
23 /**
24 * The timestamp of the last file change
25 * readonly
26 */
27 get lastmod(): Date;
28 /**
29 * The file size in bytes
30 * readonly
31 */
32 get size(): number;
33 /**
34 * The mime type (content type) of the file
35 */
36 get mime(): string;
37 /**
38 * The unique id of the file.
39 */
40 get id(): number;
41 /**
42 * deletes a file
43 * @throws Error
44 */
45 delete(): Promise<void>;
46 /**
47 * get folder of the file
48 * @throws ClientError
49 * @returns the parent folder
50 */
51 getFolder(): Promise<Folder>;
52 /**
53 * moves or renames the current file to the new location
54 * target folder must exists
55 * @param targetFileName the name of the target file /f1/f2/myfile.txt
56 * @throws Error
57 */
58 move(targetFileName: string): Promise<File>;
59 /**
60 * @returns the buffer of the file content
61 * @throws Error
62 */
63 getContent(): Promise<Buffer>;
64 /**
65 * @returns the url of the file
66 * @throws Error
67 */
68 getUrl(): string;
69 /**
70 * @returns the url of the file in the UI
71 * @throws Error
72 */
73 getUIUrl(): string;
74 /**
75 * adds a tag name to the file
76 * @param tagName name of the tag
77 */
78 addTag(tagName: string): Promise<void>;
79 /**
80 * get tag names
81 * @returns array of tag names
82 */
83 getTags(): Promise<string[]>;
84 /**
85 * removes a tag of the file
86 * @param tagName the name of the tag
87 */
88 removeTag(tagName: string): Promise<void>;
89 /**
90 * add comment to file
91 * @param comment the comment
92 */
93 addComment(comment: string): Promise<void>;
94 /**
95 * get list of comments of file
96 * @param top number of comments to return
97 * @param skip the offset
98 * @returns array of comment strings
99 * @throws Exception
100 */
101 getComments(top?: number, skip?: number): Promise<string[]>;
102 private assertExistence;
103}