feat(blossom): optional S3-compatible blob storage #12
Reference in New Issue
Block a user
Delete Branch "userAdityaa/zooid:storage-support"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Allows each host/relay to choose local filesystem (default) or S3-compatible object storage for Blossom blobs via
blossom.file_storageand[blossom.s3].Changes
blossom.file_storage(local|s3, empty = local); nestedBlossomS3Settingswith endpoint, region, bucket, keys, optionalkey_prefix,use_path_style.secret_keymirrored to a private field after load (like relaysecret); restored only when writing TOML.validateBlossomFileStoragefromLoadConfigFromPathandAPIHandler.validateConfigwhen Blossom is enabled and storage iss3.BlossomStore.Enablebranches local vs S3; AWS SDK for Go v2 S3 client with optional customBaseEndpoint.closes #10
@@ -21,0 +34,4 @@}awsCfg, err := awsconfig.LoadDefaultConfig(ctx,awsconfig.WithRegion(strings.TrimSpace(s.Region)),Again, normalization should be done when parsing config
@@ -33,1 +63,3 @@file, err := fs.Create(dir + "/" + sha256)fs := strings.ToLower(strings.TrimSpace(bl.Config.Blossom.FileStorage))if fs == "" {fs = "local"Fallback when parsing config, also normalize there, we shouldn't have to normalize here.
@@ -34,0 +96,4 @@return osfs.Remove(filepath.Join(dir, sha256))}case "s3":Separate these into separate functions instead of factoring out newBlossomS3Client
@@ -61,1 +63,3 @@secret nostr.SecretKeypath stringsecret nostr.SecretKeyblossomS3SecretKey stringLet's not do this, s3 secret isn't super sensitive, just leave it in the s3 settings struct
@@ -157,0 +218,4 @@[blossom]enabled = truefile_storage = "s3"Rename this to
backend@@ -157,0 +226,4 @@access_key = "AKIA"secret_key = "topsecret"endpoint = "http://127.0.0.1:9000"use_path_style = trueThis should probably not be configurable, just use what makes sense.
4f3addc4a4tof46ba28aeff46ba28aefto732f9b6209Merged via
f40e909863Also take a look at
ea145079f4for how I refactored this — there was a lot of confusing aliasing and ordering of utility functions that made the code hard to follow. I also cleaned up api.go which was adding to the confusion over where validation belongs.Pull request closed