1+ using System ;
2+ using System . Collections . Generic ;
3+ using System . IO ;
4+ using System . Threading ;
5+ using System . Threading . Tasks ;
6+ using ManagedCode . Communication ;
7+ using ManagedCode . Storage . Core . Models ;
8+
9+ namespace ManageCode . FileStream . Client . Abstractions ;
10+ public interface IFileEndpoint
11+ {
12+
13+
14+ public Task UploadAsync ( string [ ] filesPath ) ;
15+ }
16+
17+ public class Prog
18+ {
19+ public void Do ( )
20+ {
21+ IFileClient client ;
22+
23+ var a = client . UploadAsync ( x => x . FromPath ( "file path" ) ) ;
24+ }
25+ }
26+
27+ public class FileUploadExtensions
28+ {
29+
30+ /// <summary>
31+ /// Upload data from the stream into the blob storage.
32+ /// </summary>
33+ Task < Result < BlobMetadata > > UploadAsync ( Stream stream , CancellationToken cancellationToken = default ) ;
34+
35+ /// <summary>
36+ /// Upload array of bytes into the blob storage.
37+ /// </summary>
38+ Task < Result < BlobMetadata > > UploadAsync ( byte [ ] data , CancellationToken cancellationToken = default ) ;
39+
40+ /// <summary>
41+ /// Upload data from the string into the blob storage.
42+ /// </summary>
43+ Task < Result < BlobMetadata > > UploadAsync ( string content , CancellationToken cancellationToken = default ) ;
44+
45+ /// <summary>
46+ /// Upload data from the file into the blob storage.
47+ /// </summary>
48+ Task < Result < BlobMetadata > > UploadAsync ( FileInfo fileInfo , CancellationToken cancellationToken = default ) ;
49+
50+ /// <summary>
51+ /// Upload data from the stream into the blob storage.
52+ /// </summary>
53+ Task < Result < BlobMetadata > > UploadAsync ( Stream stream , UploadOptions options , CancellationToken cancellationToken = default ) ;
54+
55+ /// <summary>
56+ /// Upload array of bytes into the blob storage.
57+ /// </summary>
58+ Task < Result < BlobMetadata > > UploadAsync ( byte [ ] data , UploadOptions options , CancellationToken cancellationToken = default ) ;
59+
60+ /// <summary>
61+ /// Upload data from the string into the blob storage.
62+ /// </summary>
63+ Task < Result < BlobMetadata > > UploadAsync ( string content , UploadOptions options , CancellationToken cancellationToken = default ) ;
64+
65+ /// <summary>
66+ /// Upload data from the file into the blob storage.
67+ /// </summary>
68+ Task < Result < BlobMetadata > > UploadAsync ( FileInfo fileInfo , UploadOptions options , CancellationToken cancellationToken = default ) ;
69+
70+ /// <summary>
71+ /// Upload data from the stream into the blob storage.
72+ /// </summary>
73+ Task < Result < BlobMetadata > > UploadAsync ( Stream stream , Action < UploadOptions > action , CancellationToken cancellationToken = default ) ;
74+
75+ /// <summary>
76+ /// Upload array of bytes into the blob storage.
77+ /// </summary>
78+ Task < Result < BlobMetadata > > UploadAsync ( byte [ ] data , Action < UploadOptions > action , CancellationToken cancellationToken = default ) ;
79+
80+ /// <summary>
81+ /// Upload data from the string into the blob storage.
82+ /// </summary>
83+ Task < Result < BlobMetadata > > UploadAsync ( string content , Action < UploadOptions > action , CancellationToken cancellationToken = default ) ;
84+
85+ /// <summary>
86+ /// Upload data from the file into the blob storage.
87+ /// </summary>
88+ Task < Result < BlobMetadata > > UploadAsync ( FileInfo fileInfo , Action < UploadOptions > action , CancellationToken cancellationToken = default ) ;
89+ }
90+
91+ public class BlobMetaData
92+ {
93+
94+ }
95+
96+
97+ public interface IBlobStorage < TStorage > :
98+ IFileUploader < BlobMetaData , UploadOptions > ,
99+ IFileDownloader < BlobMetaData , DownloadOptions > ,
100+ IFileDeleter < object , object > ,
101+ ILegalHold ,
102+ IMetaDataReader < object > , IStorageOptions < TStorage >
103+
104+ {
105+ public Task < bool > IsFileExistsAsync ( Action < IFileChooser > file ) ;
106+
107+ Task CreateContainerAsync ( CancellationToken cancellationToken = default ) ;
108+
109+ /// <summary>
110+ /// Delete a container if it does not already exist.
111+ /// </summary>
112+ Task RemoveContainerAsync ( CancellationToken cancellationToken = default ) ;
113+
114+ Task DeleteDirectoryAsync ( string directory , CancellationToken cancellationToken = default ) ;
115+ }
116+
117+ public interface IStorageOptions < TOptions >
118+ {
119+ Task SetStorageOptions ( TOptions options , CancellationToken cancellationToken = default ) ;
120+ Task SetStorageOptions ( Action < TOptions > options , CancellationToken cancellationToken = default ) ;
121+ }
122+
123+ public interface IMetaDataReader < TMetaData >
124+ {
125+ public Task < TMetaData > GetMetaDataAsync ( Action < IFileChooser > file , CancellationToken token = default ) ;
126+
127+ IAsyncEnumerable < TMetaData > GetBlobMetadataListAsync ( string ? directory = null , CancellationToken cancellationToken = default ) ;
128+ }
129+
130+ public interface ILegalHold
131+ {
132+ public Task SetLegalHoldAsync ( Action < IFileChooser > file , bool legalHoldStatus , CancellationToken cancellationToken = default ) ;
133+
134+ public Task HasLegalHold ( Action < IFileChooser > file , CancellationToken cancellationToken = default ) ;
135+ }
136+
137+ public interface IFileUploader < TResult , TOptions >
138+ where TOptions : class
139+ {
140+ public Task < TResult > UploadAsync ( Action < IFileReader > file , TOptions ? options = null ,
141+ ProgressHandler ? progressHandler = null , CancellationToken ? token = null ) ;
142+
143+ }
144+
145+
146+ public interface IFileDownloader < TResult , TOptions >
147+ where TOptions : class
148+ {
149+ public Task < TResult > DownloadAsync ( Action < IFileChooser > fileChooser , TOptions ? options = null ,
150+ ProgressHandler ? progressHandler = null , CancellationToken ? token = null ) ;
151+ }
152+
153+ public interface IFileDeleter < TResult , TOptions >
154+ where TOptions : class
155+ {
156+ public Task < TResult > DeleteAsync ( Action < IFileChooser > file , TOptions ? options = null , CancellationToken ? token = null ) ;
157+ }
158+
159+
160+ public interface IFileChooser
161+ {
162+ public IFileChooser FromUrl ( string url ) ;
163+
164+ public void FromDirectory ( string directory , string fileName ) ;
165+ }
166+
167+ public class DownloadOptions
168+ {
169+
170+ }
171+
172+ public class UploadOptions
173+ {
174+
175+ }
176+
177+ public class UploadResult
178+ {
179+
180+ }
181+
182+ public delegate void ProgressHandler ( object sender , ProgressArgs args ) ;
183+
184+ public class ProgressArgs
185+ {
186+
187+ }
188+
189+
190+ public interface IFileClient : IFileUploader , IFileDownloader
191+ {
192+
193+ }
194+
195+ public interface IFileReader
196+ {
197+ public void FromPath ( string filePath ) ;
198+
199+ public void FromFileInfo ( FileInfo info ) ;
200+
201+ public void FromStream ( Stream stream ) ;
202+
203+ public void FromBytes ( byte [ ] bytes ) ;
204+ }
205+
206+ internal class FileReader : IFileReader
207+ {
208+ public void FromPath ( string filePath )
209+ {
210+ throw new NotImplementedException ( ) ;
211+ }
212+
213+ public void FromFileInfo ( FileInfo info )
214+ {
215+ throw new NotImplementedException ( ) ;
216+ }
217+
218+ public void FromStream ( Stream stream )
219+ {
220+ throw new NotImplementedException ( ) ;
221+ }
222+
223+ public void FromBytes ( byte [ ] bytes )
224+ {
225+ throw new NotImplementedException ( ) ;
226+ }
227+ }
0 commit comments