diff --git a/pkg/internal/fs/downloader.go b/pkg/internal/fs/downloader.go index 7436892..56d9813 100644 --- a/pkg/internal/fs/downloader.go +++ b/pkg/internal/fs/downloader.go @@ -6,6 +6,7 @@ import ( "os" "path/filepath" + pkg "git.solsynth.dev/hypernet/paperclip/pkg/internal" "git.solsynth.dev/hypernet/paperclip/pkg/internal/models" jsoniter "github.com/json-iterator/go" "github.com/minio/minio-go/v7" @@ -31,9 +32,11 @@ func DownloadFileToLocal(meta models.Attachment, dst int) (string, error) { _ = jsoniter.Unmarshal(rawDest, &destConfigured) client, err := minio.New(destConfigured.Endpoint, &minio.Options{ - Creds: credentials.NewStaticV4(destConfigured.SecretID, destConfigured.SecretKey, ""), - Secure: destConfigured.EnableSSL, + Creds: credentials.NewStaticV4(destConfigured.SecretID, destConfigured.SecretKey, ""), + Secure: destConfigured.EnableSSL, + BucketLookup: minio.BucketLookupType(destConfigured.BucketLookup), }) + client.SetAppInfo("HyperNet.Paperclip", pkg.AppVersion) if err != nil { return "", fmt.Errorf("unable to configure s3 client: %v", err) } diff --git a/pkg/internal/fs/recycler.go b/pkg/internal/fs/recycler.go index 35f519a..24bd6a5 100644 --- a/pkg/internal/fs/recycler.go +++ b/pkg/internal/fs/recycler.go @@ -7,6 +7,7 @@ import ( "path/filepath" "time" + pkg "git.solsynth.dev/hypernet/paperclip/pkg/internal" "git.solsynth.dev/hypernet/paperclip/pkg/internal/database" "github.com/samber/lo" @@ -121,9 +122,11 @@ func DeleteFileFromLocal(config models.LocalDestination, uuid string) error { func DeleteFileFromS3(config models.S3Destination, uuid string) error { client, err := minio.New(config.Endpoint, &minio.Options{ - Creds: credentials.NewStaticV4(config.SecretID, config.SecretKey, ""), - Secure: config.EnableSSL, + Creds: credentials.NewStaticV4(config.SecretID, config.SecretKey, ""), + Secure: config.EnableSSL, + BucketLookup: minio.BucketLookupType(config.BucketLookup), }) + client.SetAppInfo("HyperNet.Paperclip", pkg.AppVersion) if err != nil { return fmt.Errorf("unable to configure s3 client: %v", err) } diff --git a/pkg/internal/models/destination.go b/pkg/internal/models/destination.go index 72363c2..62056ff 100644 --- a/pkg/internal/models/destination.go +++ b/pkg/internal/models/destination.go @@ -31,4 +31,5 @@ type S3Destination struct { AccessBaseURL string `json:"access_baseurl"` EnableSSL bool `json:"enable_ssl"` EnableSigned bool `json:"enable_signed"` + BucketLookup int `json:"bucket_lookup"` } diff --git a/pkg/internal/services/opener.go b/pkg/internal/services/opener.go index a3b16ea..ab11304 100644 --- a/pkg/internal/services/opener.go +++ b/pkg/internal/services/opener.go @@ -9,6 +9,7 @@ import ( "path/filepath" "time" + pkg "git.solsynth.dev/hypernet/paperclip/pkg/internal" localCache "git.solsynth.dev/hypernet/paperclip/pkg/internal/cache" "git.solsynth.dev/hypernet/paperclip/pkg/internal/database" "git.solsynth.dev/hypernet/paperclip/pkg/internal/models" @@ -118,9 +119,11 @@ func OpenAttachmentByRID(rid string, region ...string) (url string, mimetype str if destConfigured.EnableSigned { var client *minio.Client client, err = minio.New(destConfigured.Endpoint, &minio.Options{ - Creds: credentials.NewStaticV4(destConfigured.SecretID, destConfigured.SecretKey, ""), - Secure: destConfigured.EnableSSL, + Creds: credentials.NewStaticV4(destConfigured.SecretID, destConfigured.SecretKey, ""), + Secure: destConfigured.EnableSSL, + BucketLookup: minio.BucketLookupType(destConfigured.BucketLookup), }) + client.SetAppInfo("HyperNet.Paperclip", pkg.AppVersion) if err != nil { return } diff --git a/pkg/internal/services/uploader.go b/pkg/internal/services/uploader.go index 014f154..25a5991 100644 --- a/pkg/internal/services/uploader.go +++ b/pkg/internal/services/uploader.go @@ -8,6 +8,7 @@ import ( "os" "path/filepath" + pkg "git.solsynth.dev/hypernet/paperclip/pkg/internal" "git.solsynth.dev/hypernet/paperclip/pkg/internal/database" "git.solsynth.dev/hypernet/paperclip/pkg/internal/fs" "git.solsynth.dev/hypernet/paperclip/pkg/internal/models" @@ -92,9 +93,11 @@ func ReUploadFile(meta models.Attachment, dst int, doNotUpdate ...bool) error { _ = jsoniter.Unmarshal(rawDest, &destConfigured) client, err := minio.New(destConfigured.Endpoint, &minio.Options{ - Creds: credentials.NewStaticV4(destConfigured.SecretID, destConfigured.SecretKey, ""), - Secure: destConfigured.EnableSSL, + Creds: credentials.NewStaticV4(destConfigured.SecretID, destConfigured.SecretKey, ""), + Secure: destConfigured.EnableSSL, + BucketLookup: minio.BucketLookupType(destConfigured.BucketLookup), }) + client.SetAppInfo("HyperNet.Paperclip", pkg.AppVersion) if err != nil { return fmt.Errorf("unable to configure s3 client: %v", err) }