A library to manage files in an organized, efficient and simple manner.
The default IFileService implementation which is provided. Requires an instance of IFileServiceConfig in order to work.
The default IFileServiceConfig implementation provided.
The default IFileMetaData implementation provided.
This Enum is not actually physically included in this package, but is rather inherited from the DotNetOpen.FileService.Abstractions and defines the units of size used throughout the whole package.
In order to use the functionalities provided within the library, you must create or load an instance of IFileServiceConfig
var allowedExtensions = new string[] {"zip", "mp3", "png", "jpg", "gif"};
var config = new FileServiceConfig(
stream => "application/octet-stream",
28,
FileSizeUnit.MB,
Path.Combine(Environment.CurrentDirectory, "Files"),
allowedExtensions);
var fileService = new FileService(config);
Now, imagining that you have a zip file in a stream named 'stream' in order to save a stream into a file
var fileMetaData = await fileService.CreateAsync("thefile.zip", "zip", stream);
This gives you a variable of type 'IFileMetaData' which contains the basic information of the file which we just saved.
Now imagining that you want to get the data of the newly created file into a stream named 'strm'
var metaData = fileService.GetFile("thefile.zip", "zip");