Skip to content

Commit

Permalink
Adds a new --acl option that allows to set the canned ACL to be appli…
Browse files Browse the repository at this point in the history
…ed to

the object. Default is off. Allowed values are private | public-read |
public-read-write | authenticated-read | aws-exec-read | bucket-owner-read
| bucket-owner-full-control.
  • Loading branch information
monken committed Oct 17, 2016
1 parent eae9137 commit 91ab237
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
9 changes: 9 additions & 0 deletions internal/flags.go
Expand Up @@ -154,6 +154,13 @@ func NewApp() (app *cli.App) {
Value: "",
},

/// http://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl
cli.StringFlag{
Name: "acl",
Usage: "The canned ACL to apply to the object (default: off, allowed values: private, public-read, public-read-write, authenticated-read, aws-exec-read, bucket-owner-read, bucket-owner-full-control)",
Value: "",
},

/////////////////////////
// Tuning
/////////////////////////
Expand Down Expand Up @@ -214,6 +221,7 @@ type FlagStorage struct {
UseSSE bool
UseKMS bool
KMSKeyID string
ACL string

// Tuning
StatCacheTTL time.Duration
Expand Down Expand Up @@ -274,6 +282,7 @@ func PopulateFlags(c *cli.Context) (flags *FlagStorage) {
UseSSE: c.Bool("sse"),
UseKMS: c.IsSet("sse-kms"),
KMSKeyID: c.String("sse-kms"),
ACL: c.String("acl"),

// Debugging,
DebugFuse: c.Bool("debug_fuse"),
Expand Down
8 changes: 8 additions & 0 deletions internal/goofys.go
Expand Up @@ -572,6 +572,10 @@ func (fs *Goofys) copyObjectMultipart(size int64, from string, to string, mpuId
}
}

if fs.flags.ACL != "" {
params.ACL = &fs.flags.ACL
}

resp, err := fs.s3.CreateMultipartUpload(params)
if err != nil {
return mapAwsError(err)
Expand Down Expand Up @@ -653,6 +657,10 @@ func (fs *Goofys) copyObjectMaybeMultipart(size int64, from string, to string) (
}
}

if fs.flags.ACL != "" {
params.ACL = &fs.flags.ACL
}

_, err = fs.s3.CopyObject(params)
if err != nil {
err = mapAwsError(err)
Expand Down
8 changes: 8 additions & 0 deletions internal/handles.go
Expand Up @@ -391,6 +391,10 @@ func (fh *FileHandle) initMPU(fs *Goofys) {
}
}

if fs.flags.ACL != "" {
params.ACL = &fs.flags.ACL
}

resp, err := fs.s3.CreateMultipartUpload(params)

fh.mu.Lock()
Expand Down Expand Up @@ -892,6 +896,10 @@ func (fh *FileHandle) flushSmallFile(fs *Goofys) (err error) {
}
}

if fs.flags.ACL != "" {
params.ACL = &fs.flags.ACL
}

fs.replicators.Take(1, true)
defer fs.replicators.Return(1)

Expand Down

0 comments on commit 91ab237

Please sign in to comment.