-
Notifications
You must be signed in to change notification settings - Fork 8
File management (Web folders, S3 Cloud services and other)
Starting from v4.0.0
we added file management interfaces and 2 implementations based on Web Folders and S3 AWS. Due to many developers regularly facing this task and this is a boilerplate code that could be moved to Wissance.WebApiToolkit
. The file management system does not have some common controller because files could be related to database objects; therefore, we just created a Manager
interface and events for the notifications. Wiring managers for database and file operations is on a library user until we find a more appropriate way of managing them together. Common file manager is IFileManager
Web Folder is a filesystem folder that is accessible by Web Application and exposed to Web Application Users to perform operations with files and disks. Implementation based on Web Folder usage is located in Core
lib because it does not depend on non-FCL
packages and could be considered as a common. There is one thing that should be noted: WebFolderFileManager
could work with multiple storage. In the case of Web Folder storage = web folder root directory, that means that this manager could work with multiple Web Folders. There is a unit test example of how to use WebFolderFileManager
in the app, see all path that are using in operation are relative to WebFolder directory.
S3 originally was an Amazon abbreviation, but AWS S3 services are supported by other cloud services like Cloudflare R2
or Yandex Object Storage
, therefore AWS-based implementation could be used for various services at the same time. See implementation here. Latter manager, like a WebFolderFileManager
supports multiple storages, but in the case of S3 Cloud Service, it means a new connection to other cloud services. There are also example of how to use AWSCompatibleCloudFileStorageManager
with Yandex, see . For proper test run there should be done the following:
- You should create setting.json file with content like (example):
{
"AccessKey": "YassEZBPassMGzTelzassigfQ",
"SecretAccessKey": "YCMeYuWMassSWPBAasselV7assQ0assDNUassdkS"
}
-
Access
andSecretAccessKey
must be related with an account with thestorage.editor
role. - We are expecting 2 buckets -
y-s3-test-bucket
andy-s3-test-bucket-2
to be created prior to tests being run. - bucket
y-s3-test-bucket-2
must have the following file structure:
/
--/artifacts
--/archives
--/txt
--/test_data.txt (content: test_data:1234567890 qwertyuiopasdfghjklzxcvbnm)
--/test_data2.txt (content: 01234567890987654321)
--/bin
--/docs
--/src