You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Global issue: Downloading and uploading files should be an easy task in FoalTS, whether we use the local file system or a Cloud storage (such as Amazon S3).
This particular issue: For this, we need an agnostic file storage where it will be easy to switch drivers from one environment to another. For example, with the same code but with different configuration files, we would use the local file system when developing the application locally and use AWS S3 when deploying the application to staging or production.
TODO: Think how errors should be handled (especially errors in streams).
Create a new package named @foal/storage.
Add the abstract class AbstractDisk. All disks should inherit this class. Take a look at the function createHttpResponseFile when implementing the createHttpResponse method.
Add the class LocalDisk. This class will use Node fs package and use the configuration key settings.disk.directory. Take also a look at the function createHttpResponseFile.
Add the class S3Disk. This class will use AWS SDK and use the configuration key settings.disk.bucket. In an external package called @foal/aws-s3?
Add the class Disk. This class will use the configuration settings.disk.drive to choose which disk to use.
Additional Notes
In future major versions, remove createHttpResponseFile as it can be replaced with this.disk.createHttpReponse and remove mime from @foal/core dependencies.
LoicPoullain
changed the title
Have an agnostic filesystem that supports both local and Cloud storages (such as AWS S3)
Have a filesystem that supports both local and Cloud storages (such as AWS S3)
Feb 12, 2020
Issue
Global issue: Downloading and uploading files should be an easy task in FoalTS, whether we use the local file system or a Cloud storage (such as Amazon S3).
This particular issue: For this, we need an agnostic file storage where it will be easy to switch drivers from one environment to another. For example, with the same code but with different configuration files, we would use the local file system when developing the application locally and use AWS S3 when deploying the application to staging or production.
Solution and Examples
Write files (examples)
Read files (examples)
Delete files (examples)
Download files in streaming (HTTP response)
Configuration file for the local file system
Configuration file for AWS S3
Steps
TODO: Think how errors should be handled (especially errors in streams).
Create a new package named
@foal/storage
.Add the abstract class
AbstractDisk
. All disks should inherit this class. Take a look at the functioncreateHttpResponseFile
when implementing thecreateHttpResponse
method.Add the class
LocalDisk
. This class will use Nodefs
package and use the configuration keysettings.disk.directory
. Take also a look at the functioncreateHttpResponseFile
.Add the class
S3Disk
. This class will use AWS SDK and use the configuration keysettings.disk.bucket
. In an external package called@foal/aws-s3
?Add the class
Disk
. This class will use the configurationsettings.disk.drive
to choose which disk to use.Additional Notes
createHttpResponseFile
as it can be replaced withthis.disk.createHttpReponse
and removemime
from@foal/core
dependencies.Resources
Related issues
#421
#560
The text was updated successfully, but these errors were encountered: