afero-s3
afero-s3 copied to clipboard
Subdir in S3?
Is there any way to create a FS that accesses only a subdir in S3? (basically a prefix/ to everything)
Small edit for clarification: I have seen afero.NewBasePathFs but I am not sure if it is a good direction
diff --git a/fs/s3/s3.go b/fs/s3/s3.go
index b4756f8..ae2e413 100644
--- a/fs/s3/s3.go
+++ b/fs/s3/s3.go
@@ -18,6 +18,7 @@ func LoadFs(access *confpar.Access) (afero.Fs, error) {
bucket := access.Params["bucket"]
keyID := access.Params["access_key_id"]
secretAccessKey := access.Params["secret_access_key"]
+ basePath := access.Params["base_path"]
conf := aws.Config{
Region: aws.String(region),
@@ -42,6 +43,9 @@ func LoadFs(access *confpar.Access) (afero.Fs, error) {
s3Fs := s3.NewFs(bucket, sess)
// s3Fs = stripprefix.NewStripPrefixFs(s3Fs, 1)
-
- return s3Fs, nil
+ if basePath != "" {
+ return afero.NewBasePathFs(s3Fs, basePath), nil
+ } else {
+ return s3Fs, nil
+ }
}