Backend File Manager¶
The purpose for this service is to upload/download files to/from FileStorage
from a backend service.
In order to use the File Manager we need to reference
the FileManagerClient
project:
XML | |
---|---|
And add the dependency in the application module:
C# | |
---|---|
Also, we need to configure the Service Discovery module, for this we need to add
the following options to our appsettings.json
:
Now we are ready to inject the IFileManager
interface to our services and
we can use the following methods:
Upload
: Uploads a single file asynchronously and returns its Guid when the upload is fully completed.UploadMultiple
: Uploads a list of files asynchronously and returns a list of Guids when all uploads are fully completed.Download
: Returns an asynchronous FileStream for a given file Correlation Id.UploadTemporalFile
: Works the same way that the normal Upload but adds a metadata value that make the file "temporal". This means that the File will be stored in other folder and won't be replicated. Also the lifetime of the file should be shorter than a normal file. A use case example is an attachment of an email.UploadMultipleTemporal
: The upload multiple counterpart for temporal files.DownloadTemporalFile
: The download counterpart for temporal files.DeleteFile
: Publishes a message to delete a file physically. This method could be used when doing a rollback for compensating a Saga.
Local testing¶
If you want to test this running FileStorage in your IDE
(or exposing the port 22005 of the pod/container), we need to add one more entry to
our appsettings.json
:
JSON | |
---|---|
Note
This last configuration is done in docker.host.config.json
for the
dev environment.