wasDAVClient – Diff between revs 3 and 5
?pathlinks?
Rev 3 | Rev 5 | |||
---|---|---|---|---|
- | 1 | /////////////////////////////////////////////////////////////////////////// |
||
- | 2 | // Copyright (C) Wizardry and Steamworks 2016 - License: GNU GPLv3 // |
||
- | 3 | // Please see: http://www.gnu.org/licenses/gpl.html for legal details, // |
||
- | 4 | // rights of fair usage, the disclaimer and warranty conditions. // |
||
- | 5 | /////////////////////////////////////////////////////////////////////////// |
||
- | 6 | // Originally based on: WebDAV .NET client by Sergey Kazantsev |
||
- | 7 | |
||
1 | using System.Collections.Generic; |
8 | using System.Collections.Generic; |
|
2 | using System.IO; |
9 | using System.IO; |
|
3 | using System.Threading.Tasks; |
10 | using System.Threading.Tasks; |
|
4 | using wasDAVClient.Model; |
11 | using wasDAVClient.Model; |
|
5 | |
12 | |
|
6 | namespace wasDAVClient |
13 | namespace wasDAVClient |
|
7 | { |
14 | { |
|
8 | public interface IClient |
15 | public interface IClient |
|
9 | { |
16 | { |
|
10 | /// <summary> |
17 | /// <summary> |
|
11 | /// Specify the WebDAV hostname (required). |
18 | /// Specify the WebDAV hostname (required). |
|
12 | /// </summary> |
19 | /// </summary> |
|
13 | string Server { get; set; } |
20 | string Server { get; set; } |
|
14 | |
21 | |
|
15 | /// <summary> |
22 | /// <summary> |
|
16 | /// Specify the path of a WebDAV directory to use as 'root' (default: /) |
23 | /// Specify the path of a WebDAV directory to use as 'root' (default: /) |
|
17 | /// </summary> |
24 | /// </summary> |
|
18 | string BasePath { get; set; } |
25 | string BasePath { get; set; } |
|
19 | |
26 | |
|
20 | /// <summary> |
27 | /// <summary> |
|
21 | /// Specify an port (default: null = auto-detect) |
28 | /// Specify an port (default: null = auto-detect) |
|
22 | /// </summary> |
29 | /// </summary> |
|
23 | int? Port { get; set; } |
30 | int? Port { get; set; } |
|
24 | |
31 | |
|
25 | /// <summary> |
32 | /// <summary> |
|
26 | /// Specify the UserAgent (and UserAgent version) string to use in requests |
33 | /// Specify the UserAgent (and UserAgent version) string to use in requests |
|
27 | /// </summary> |
34 | /// </summary> |
|
28 | string UserAgent { get; set; } |
35 | string UserAgent { get; set; } |
|
29 | |
36 | |
|
30 | /// <summary> |
37 | /// <summary> |
|
31 | /// Specify the UserAgent (and UserAgent version) string to use in requests |
38 | /// Specify the UserAgent (and UserAgent version) string to use in requests |
|
32 | /// </summary> |
39 | /// </summary> |
|
33 | string UserAgentVersion { get; set; } |
40 | string UserAgentVersion { get; set; } |
|
34 | |
41 | |
|
35 | |
42 | |
|
36 | /// <summary> |
43 | /// <summary> |
|
37 | /// List all files present on the server. |
44 | /// List all files present on the server. |
|
38 | /// </summary> |
45 | /// </summary> |
|
39 | /// <param name="path">List only files in this path</param> |
46 | /// <param name="path">List only files in this path</param> |
|
40 | /// <param name="depth">Recursion depth</param> |
47 | /// <param name="depth">Recursion depth</param> |
|
41 | /// <returns>A list of files (entries without a trailing slash) and directories (entries with a trailing slash)</returns> |
48 | /// <returns>A list of files (entries without a trailing slash) and directories (entries with a trailing slash)</returns> |
|
42 | Task<IEnumerable<Item>> List(string path = "/", int? depth = 1); |
49 | Task<IEnumerable<Item>> List(string path = "/", int? depth = 1); |
|
43 | |
50 | |
|
44 | /// <summary> |
51 | /// <summary> |
|
45 | /// Get folder information from the server. |
52 | /// Get folder information from the server. |
|
46 | /// </summary> |
53 | /// </summary> |
|
47 | /// <returns>A list of files (entries without a trailing slash) and directories (entries with a trailing slash)</returns> |
54 | /// <returns>A list of files (entries without a trailing slash) and directories (entries with a trailing slash)</returns> |
|
48 | Task<Item> GetFolder(string path = "/"); |
55 | Task<Item> GetFolder(string path = "/"); |
|
49 | |
56 | |
|
50 | /// <summary> |
57 | /// <summary> |
|
51 | /// Get file information from the server. |
58 | /// Get file information from the server. |
|
52 | /// </summary> |
59 | /// </summary> |
|
53 | /// <returns>A list of files (entries without a trailing slash) and directories (entries with a trailing slash)</returns> |
60 | /// <returns>A list of files (entries without a trailing slash) and directories (entries with a trailing slash)</returns> |
|
54 | Task<Item> GetFile(string path = "/"); |
61 | Task<Item> GetFile(string path = "/"); |
|
55 | |
62 | |
|
56 | /// <summary> |
63 | /// <summary> |
|
57 | /// Download a file from the server |
64 | /// Download a file from the server |
|
58 | /// </summary> |
65 | /// </summary> |
|
59 | /// <param name="remoteFilePath">Source path and filename of the file on the server</param> |
66 | /// <param name="remoteFilePath">Source path and filename of the file on the server</param> |
|
60 | Task<Stream> Download(string remoteFilePath); |
67 | Task<Stream> Download(string remoteFilePath); |
|
61 | |
68 | |
|
62 | /// <summary> |
69 | /// <summary> |
|
63 | /// Download a file from the server |
70 | /// Download a file from the server |
|
64 | /// </summary> |
71 | /// </summary> |
|
65 | /// <param name="remoteFilePath">Source path and filename of the file on the server</param> |
72 | /// <param name="remoteFilePath">Source path and filename of the file on the server</param> |
|
66 | /// <param name="content"></param> |
73 | /// <param name="content"></param> |
|
67 | /// <param name="name"></param> |
74 | /// <param name="name"></param> |
|
68 | Task<bool> Upload(string remoteFilePath, Stream content, string name); |
75 | Task<bool> Upload(string remoteFilePath, Stream content, string name); |
|
69 | |
76 | |
|
70 | /// <summary> |
77 | /// <summary> |
|
71 | /// Create a directory on the server |
78 | /// Create a directory on the server |
|
72 | /// </summary> |
79 | /// </summary> |
|
73 | /// <param name="remotePath">Destination path of the directory on the server</param> |
80 | /// <param name="remotePath">Destination path of the directory on the server</param> |
|
74 | /// <param name="name"></param> |
81 | /// <param name="name"></param> |
|
75 | Task<bool> CreateDir(string remotePath, string name); |
82 | Task<bool> CreateDir(string remotePath, string name); |
|
76 | |
83 | |
|
77 | /// <summary> |
84 | /// <summary> |
|
78 | /// Get folder information from the server. |
85 | /// Get folder information from the server. |
|
79 | /// </summary> |
86 | /// </summary> |
|
80 | /// <returns>A list of files (entries without a trailing slash) and directories (entries with a trailing slash)</returns> |
87 | /// <returns>A list of files (entries without a trailing slash) and directories (entries with a trailing slash)</returns> |
|
81 | Task DeleteFolder(string path = "/"); |
88 | Task DeleteFolder(string path = "/"); |
|
82 | |
89 | |
|
83 | /// <summary> |
90 | /// <summary> |
|
84 | /// Get file information from the server. |
91 | /// Get file information from the server. |
|
85 | /// </summary> |
92 | /// </summary> |
|
86 | /// <returns>A list of files (entries without a trailing slash) and directories (entries with a trailing slash)</returns> |
93 | /// <returns>A list of files (entries without a trailing slash) and directories (entries with a trailing slash)</returns> |
|
87 | Task DeleteFile(string path = "/"); |
94 | Task DeleteFile(string path = "/"); |
|
88 | |
95 | |
|
89 | /// <summary> |
96 | /// <summary> |
|
90 | /// Move a folder on the server |
97 | /// Move a folder on the server |
|
91 | /// </summary> |
98 | /// </summary> |
|
92 | /// <param name="srcFolderPath">Source path of the folder on the server</param> |
99 | /// <param name="srcFolderPath">Source path of the folder on the server</param> |
|
93 | /// <param name="dstFolderPath">Destination path of the folder on the server</param> |
100 | /// <param name="dstFolderPath">Destination path of the folder on the server</param> |
|
94 | Task<bool> MoveFolder(string srcFolderPath, string dstFolderPath); |
101 | Task<bool> MoveFolder(string srcFolderPath, string dstFolderPath); |
|
95 | |
102 | |
|
96 | /// <summary> |
103 | /// <summary> |
|
97 | /// Move a file on the server |
104 | /// Move a file on the server |
|
98 | /// </summary> |
105 | /// </summary> |
|
99 | /// <param name="srcFilePath">Source path and filename of the file on the server</param> |
106 | /// <param name="srcFilePath">Source path and filename of the file on the server</param> |
|
100 | /// <param name="dstFilePath">Destination path and filename of the file on the server</param> |
107 | /// <param name="dstFilePath">Destination path and filename of the file on the server</param> |
|
101 | Task<bool> MoveFile(string srcFilePath, string dstFilePath); |
108 | Task<bool> MoveFile(string srcFilePath, string dstFilePath); |
|
102 | } |
109 | } |
|
103 | } |
110 | } |
|
104 | |
111 | |
|
105 |
|
112 |
|
|
106 | |
113 | |
|
107 | |
114 | |
|
108 | |
115 | |