S3CloudStorage constructor

S3CloudStorage({
  1. required Serverpod serverpod,
  2. required String storageId,
  3. required bool public,
  4. required String region,
  5. required String bucket,
  6. String? publicHost,
})

Creates a new S3CloudStorage reference.

Implementation

S3CloudStorage({
  required Serverpod serverpod,
  required String storageId,
  required this.public,
  required this.region,
  required this.bucket,
  String? publicHost,
})  : assert(serverpod.getPassword('AWSAccessKeyId') != null,
          'AWSAccessKeyId must be present in your password.yaml file'),
      assert(serverpod.getPassword('AWSSecretKey') != null,
          'AWSSecretKey must be present in your password.yaml file'),
      _awsAccessKeyId = serverpod.getPassword('AWSAccessKeyId')!,
      _awsSecretKey = serverpod.getPassword('AWSSecretKey')!,
      super(storageId) {
  // Create client
  _s3Client = AwsS3Client(
    accessKey: _awsAccessKeyId,
    secretKey: _awsSecretKey,
    bucketId: bucket,
    region: region,
  );

  this.publicHost = publicHost ?? '$bucket.s3.$region.amazonaws.com';
}