Giter Site home page Giter Site logo

Subdir in S3? about afero-s3 HOT 2 OPEN

flozano avatar flozano commented on June 26, 2024
Subdir in S3?

from afero-s3.

Comments (2)

flozano avatar flozano commented on June 26, 2024

Small edit for clarification: I have seen afero.NewBasePathFs but I am not sure if it is a good direction

from afero-s3.

flozano avatar flozano commented on June 26, 2024
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
+       }
 }

from afero-s3.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.