summaryrefslogtreecommitdiff
path: root/Remote/S3.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-06-05 14:38:01 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-06-05 14:38:01 -0400
commite9ab4e21fd215048e63f37d458e69f3f848ed5cb (patch)
treea3411387e53b8b45c4e92232b66b004243846dbc /Remote/S3.hs
parent88898179b355ea80d5afa6ede9b931c6d5e84144 (diff)
public=yes config to send AclPublicRead
In my tests, this has to be set when uploading a file to the bucket and then the file can be accessed using the bucketname.s3.amazonaws.com url. Setting it when creating the bucket didn't seem to make the whole bucket public, or allow accessing files stored in it. But I have gone ahead and also sent it when creating the bucket just in case that is needed in some case.
Diffstat (limited to 'Remote/S3.hs')
-rw-r--r--Remote/S3.hs14
1 files changed, 10 insertions, 4 deletions
diff --git a/Remote/S3.hs b/Remote/S3.hs
index 66df5a2ba..bcaf9d022 100644
--- a/Remote/S3.hs
+++ b/Remote/S3.hs
@@ -308,12 +308,13 @@ genBucket c u = do
Right _ -> noop
Left _ -> do
showAction $ "creating bucket in " ++ datacenter
- void $ sendS3Handle h $
- S3.PutBucket (bucket info) Nothing $
- mkLocationConstraint $
- T.pack datacenter
+ void $ sendS3Handle h $ S3.PutBucket
+ (bucket info)
+ (acl info)
+ locconstraint
writeUUIDFile c u info h
+ locconstraint = mkLocationConstraint $ T.pack datacenter
datacenter = fromJust $ M.lookup "datacenter" c
{- Writes the UUID to an annex-uuid file within the bucket.
@@ -430,6 +431,7 @@ data S3Info = S3Info
, metaHeaders :: [(T.Text, T.Text)]
, partSize :: Maybe Integer
, isIA :: Bool
+ , acl :: Maybe S3.CannedAcl
}
extractS3Info :: RemoteConfig -> Annex S3Info
@@ -445,6 +447,9 @@ extractS3Info c = do
, metaHeaders = getMetaHeaders c
, partSize = getPartSize c
, isIA = configIA c
+ , acl = case M.lookup "public" c of
+ Just "yes" -> Just S3.AclPublicRead
+ _ -> Nothing
}
putObject :: S3Info -> T.Text -> RequestBody -> S3.PutObject
@@ -452,6 +457,7 @@ putObject info file rbody = (S3.putObject (bucket info) file rbody)
{ S3.poStorageClass = Just (storageClass info)
, S3.poMetadata = metaHeaders info
, S3.poAutoMakeBucket = isIA info
+ , S3.poAcl = acl info
}
getBucketName :: RemoteConfig -> Maybe BucketName