summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/minio/listenbucketnotification.go3
-rw-r--r--examples/s3/bucketexists.go3
-rw-r--r--examples/s3/composeobject.go24
-rw-r--r--examples/s3/copyobject.go8
-rw-r--r--examples/s3/fgetobject-context.go54
-rw-r--r--examples/s3/fgetobject.go5
-rw-r--r--examples/s3/fputencrypted-object.go80
-rw-r--r--examples/s3/fputobject-context.go53
-rw-r--r--examples/s3/fputobject.go7
-rw-r--r--examples/s3/get-encrypted-object.go3
-rw-r--r--examples/s3/getbucketnotification.go3
-rw-r--r--examples/s3/getbucketpolicy.go3
-rw-r--r--examples/s3/getobject-context.go73
-rw-r--r--examples/s3/getobject.go5
-rw-r--r--examples/s3/listbucketpolicies.go3
-rw-r--r--examples/s3/listbuckets.go3
-rw-r--r--examples/s3/listincompleteuploads.go3
-rw-r--r--examples/s3/listobjects-N.go3
-rw-r--r--examples/s3/listobjects.go3
-rw-r--r--examples/s3/listobjectsV2.go3
-rw-r--r--examples/s3/makebucket.go3
-rw-r--r--examples/s3/presignedgetobject.go3
-rw-r--r--examples/s3/presignedheadobject.go54
-rw-r--r--examples/s3/presignedpostpolicy.go3
-rw-r--r--examples/s3/presignedputobject.go3
-rw-r--r--examples/s3/put-encrypted-object.go5
-rw-r--r--examples/s3/putobject-context.go68
-rw-r--r--examples/s3/putobject-getobject-sse.go20
-rw-r--r--examples/s3/putobject-progress.go7
-rw-r--r--examples/s3/putobject-s3-accelerate.go12
-rw-r--r--examples/s3/putobject-streaming.go5
-rw-r--r--examples/s3/putobject.go9
-rw-r--r--examples/s3/removeallbucketnotification.go3
-rw-r--r--examples/s3/removebucket.go3
-rw-r--r--examples/s3/removeincompleteupload.go3
-rw-r--r--examples/s3/removeobject.go3
-rw-r--r--examples/s3/removeobjects.go12
-rw-r--r--examples/s3/setbucketnotification.go3
-rw-r--r--examples/s3/setbucketpolicy.go3
-rw-r--r--examples/s3/statobject.go5
40 files changed, 502 insertions, 67 deletions
diff --git a/examples/minio/listenbucketnotification.go b/examples/minio/listenbucketnotification.go
index 037e225..4c48510 100644
--- a/examples/minio/listenbucketnotification.go
+++ b/examples/minio/listenbucketnotification.go
@@ -1,7 +1,8 @@
// +build ignore
/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage (C) 2015, 2016 Minio, Inc.
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage
+ * Copyright 2015-2017 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/examples/s3/bucketexists.go b/examples/s3/bucketexists.go
index 945510d..20dea30 100644
--- a/examples/s3/bucketexists.go
+++ b/examples/s3/bucketexists.go
@@ -1,7 +1,8 @@
// +build ignore
/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage (C) 2015 Minio, Inc.
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage
+ * Copyright 2015-2017 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/examples/s3/composeobject.go b/examples/s3/composeobject.go
index 555d98b..2f76ff0 100644
--- a/examples/s3/composeobject.go
+++ b/examples/s3/composeobject.go
@@ -1,7 +1,8 @@
// +build ignore
/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage (C) 2016 Minio, Inc.
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage
+ * Copyright 2015-2017 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,14 +48,14 @@ func main() {
// Source objects to concatenate. We also specify decryption
// key for each
- src1 := minio.NewSourceInfo("bucket1", "object1", decKey)
- src1.SetMatchETag("31624deb84149d2f8ef9c385918b653a")
+ src1 := minio.NewSourceInfo("bucket1", "object1", &decKey)
+ src1.SetMatchETagCond("31624deb84149d2f8ef9c385918b653a")
- src2 := minio.NewSourceInfo("bucket2", "object2", decKey)
- src2.SetMatchETag("f8ef9c385918b653a31624deb84149d2")
+ src2 := minio.NewSourceInfo("bucket2", "object2", &decKey)
+ src2.SetMatchETagCond("f8ef9c385918b653a31624deb84149d2")
- src3 := minio.NewSourceInfo("bucket3", "object3", decKey)
- src3.SetMatchETag("5918b653a31624deb84149d2f8ef9c38")
+ src3 := minio.NewSourceInfo("bucket3", "object3", &decKey)
+ src3.SetMatchETagCond("5918b653a31624deb84149d2f8ef9c38")
// Create slice of sources.
srcs := []minio.SourceInfo{src1, src2, src3}
@@ -63,11 +64,14 @@ func main() {
encKey := minio.NewSSEInfo([]byte{8, 9, 0}, "")
// Create destination info
- dst := minio.NewDestinationInfo("bucket", "object", encKey)
+ dst, err := minio.NewDestinationInfo("bucket", "object", &encKey, nil)
+ if err != nil {
+ log.Fatalln(err)
+ }
+
err = s3Client.ComposeObject(dst, srcs)
if err != nil {
- log.Println(err)
- return
+ log.Fatalln(err)
}
log.Println("Composed object successfully.")
diff --git a/examples/s3/copyobject.go b/examples/s3/copyobject.go
index 0de8655..a7c3eca 100644
--- a/examples/s3/copyobject.go
+++ b/examples/s3/copyobject.go
@@ -1,7 +1,8 @@
// +build ignore
/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage (C) 2016 Minio, Inc.
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage
+ * Copyright 2015-2017 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -60,7 +61,10 @@ func main() {
// src.SetMatchETagExceptCond("31624deb84149d2f8ef9c385918b653a")
// Destination object
- dst := minio.NewDestinationInfo("my-bucketname", "my-objectname", nil)
+ dst, err := minio.NewDestinationInfo("my-bucketname", "my-objectname", nil, nil)
+ if err != nil {
+ log.Fatalln(err)
+ }
// Initiate copy object.
err = s3Client.CopyObject(dst, src)
diff --git a/examples/s3/fgetobject-context.go b/examples/s3/fgetobject-context.go
new file mode 100644
index 0000000..6004baa
--- /dev/null
+++ b/examples/s3/fgetobject-context.go
@@ -0,0 +1,54 @@
+// +build ignore
+
+/*
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage
+ * Copyright 2017 Minio, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package main
+
+import (
+ "log"
+ "time"
+
+ "context"
+
+ "github.com/minio/minio-go"
+)
+
+func main() {
+ // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-bucketname, my-objectname
+ // and my-filename.csv are dummy values, please replace them with original values.
+
+ // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
+ // This boolean value is the last argument for New().
+
+ // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
+ // determined based on the Endpoint value.
+
+ s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
+ if err != nil {
+ log.Fatalln(err)
+ }
+
+ ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)
+ defer cancel()
+
+ if err := s3Client.FGetObjectWithContext(ctx, "my-bucketname", "my-objectname", "my-filename.csv", minio.GetObjectOptions{}); err != nil {
+ log.Fatalln(err)
+ }
+ log.Println("Successfully saved my-filename.csv")
+
+}
diff --git a/examples/s3/fgetobject.go b/examples/s3/fgetobject.go
index bef756d..819a34f 100644
--- a/examples/s3/fgetobject.go
+++ b/examples/s3/fgetobject.go
@@ -1,7 +1,8 @@
// +build ignore
/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage (C) 2015 Minio, Inc.
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage
+ * Copyright 2015-2017 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,7 +39,7 @@ func main() {
log.Fatalln(err)
}
- if err := s3Client.FGetObject("my-bucketname", "my-objectname", "my-filename.csv"); err != nil {
+ if err := s3Client.FGetObject("my-bucketname", "my-objectname", "my-filename.csv", minio.GetObjectOptions{}); err != nil {
log.Fatalln(err)
}
log.Println("Successfully saved my-filename.csv")
diff --git a/examples/s3/fputencrypted-object.go b/examples/s3/fputencrypted-object.go
new file mode 100644
index 0000000..96eec7e
--- /dev/null
+++ b/examples/s3/fputencrypted-object.go
@@ -0,0 +1,80 @@
+// +build ignore
+
+/*
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage
+ * Copyright 2017 Minio, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package main
+
+import (
+ "log"
+
+ "github.com/minio/minio-go"
+ "github.com/minio/minio-go/pkg/encrypt"
+)
+
+func main() {
+ // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-testfile, my-bucketname and
+ // my-objectname are dummy values, please replace them with original values.
+
+ // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
+ // This boolean value is the last argument for New().
+
+ // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
+ // determined based on the Endpoint value.
+ s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
+ if err != nil {
+ log.Fatalln(err)
+ }
+
+ // Specify a local file that we will upload
+ filePath := "my-testfile"
+
+ //// Build an asymmetric key from private and public files
+ //
+ // privateKey, err := ioutil.ReadFile("private.key")
+ // if err != nil {
+ // t.Fatal(err)
+ // }
+ //
+ // publicKey, err := ioutil.ReadFile("public.key")
+ // if err != nil {
+ // t.Fatal(err)
+ // }
+ //
+ // asymmetricKey, err := NewAsymmetricKey(privateKey, publicKey)
+ // if err != nil {
+ // t.Fatal(err)
+ // }
+ ////
+
+ // Build a symmetric key
+ symmetricKey := encrypt.NewSymmetricKey([]byte("my-secret-key-00"))
+
+ // Build encryption materials which will encrypt uploaded data
+ cbcMaterials, err := encrypt.NewCBCSecureMaterials(symmetricKey)
+ if err != nil {
+ log.Fatalln(err)
+ }
+
+ // Encrypt file content and upload to the server
+ n, err := s3Client.FPutEncryptedObject("my-bucketname", "my-objectname", filePath, cbcMaterials)
+ if err != nil {
+ log.Fatalln(err)
+ }
+
+ log.Println("Uploaded", "my-objectname", " of size: ", n, "Successfully.")
+}
diff --git a/examples/s3/fputobject-context.go b/examples/s3/fputobject-context.go
new file mode 100644
index 0000000..d7c941c
--- /dev/null
+++ b/examples/s3/fputobject-context.go
@@ -0,0 +1,53 @@
+// +build ignore
+
+/*
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage
+ * Copyright 2017 Minio, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package main
+
+import (
+ "log"
+ "time"
+
+ "context"
+
+ "github.com/minio/minio-go"
+)
+
+func main() {
+ // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-bucketname, my-objectname
+ // and my-filename.csv are dummy values, please replace them with original values.
+
+ // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
+ // This boolean value is the last argument for New().
+
+ // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
+ // determined based on the Endpoint value.
+
+ s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
+ if err != nil {
+ log.Fatalln(err)
+ }
+
+ ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)
+ defer cancel()
+
+ if _, err := s3Client.FPutObjectWithContext(ctx, "my-bucketname", "my-objectname", "my-filename.csv", minio.PutObjectOptions{ContentType: "application/csv"}); err != nil {
+ log.Fatalln(err)
+ }
+ log.Println("Successfully uploaded my-filename.csv")
+}
diff --git a/examples/s3/fputobject.go b/examples/s3/fputobject.go
index f4e60ac..34d8768 100644
--- a/examples/s3/fputobject.go
+++ b/examples/s3/fputobject.go
@@ -1,7 +1,8 @@
// +build ignore
/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage (C) 2015 Minio, Inc.
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage
+ * Copyright 2015-2017 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,7 +39,9 @@ func main() {
log.Fatalln(err)
}
- if _, err := s3Client.FPutObject("my-bucketname", "my-objectname", "my-filename.csv", "application/csv"); err != nil {
+ if _, err := s3Client.FPutObject("my-bucketname", "my-objectname", "my-filename.csv", minio.PutObjectOptions{
+ ContentType: "application/csv",
+ }); err != nil {
log.Fatalln(err)
}
log.Println("Successfully uploaded my-filename.csv")
diff --git a/examples/s3/get-encrypted-object.go b/examples/s3/get-encrypted-object.go
index 8f51f26..9783beb 100644
--- a/examples/s3/get-encrypted-object.go
+++ b/examples/s3/get-encrypted-object.go
@@ -1,7 +1,8 @@
// +build ignore
/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage (C) 2015 Minio, Inc.
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage
+ * Copyright 2015-2017 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/examples/s3/getbucketnotification.go b/examples/s3/getbucketnotification.go
index 67f010e..19349ba 100644
--- a/examples/s3/getbucketnotification.go
+++ b/examples/s3/getbucketnotification.go
@@ -1,7 +1,8 @@
// +build ignore
/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage (C) 2015, 2016 Minio, Inc.
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage
+ * Copyright 2015-2017 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/examples/s3/getbucketpolicy.go b/examples/s3/getbucketpolicy.go
index e5f9604..f9ac89b 100644
--- a/examples/s3/getbucketpolicy.go
+++ b/examples/s3/getbucketpolicy.go
@@ -1,7 +1,8 @@
// +build ignore
/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage (C) 2015, 2016 Minio, Inc.
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage
+ * Copyright 2015-2017 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/examples/s3/getobject-context.go b/examples/s3/getobject-context.go
new file mode 100644
index 0000000..c7d4170
--- /dev/null
+++ b/examples/s3/getobject-context.go
@@ -0,0 +1,73 @@
+// +build ignore
+
+/*
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage
+ * Copyright 2017 Minio, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package main
+
+import (
+ "io"
+ "log"
+ "os"
+ "time"
+
+ "context"
+
+ "github.com/minio/minio-go"
+)
+
+func main() {
+ // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-bucketname, my-objectname and
+ // my-testfile are dummy values, please replace them with original values.
+
+ // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
+ // This boolean value is the last argument for New().
+
+ // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
+ // determined based on the Endpoint value.
+
+ s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESS-KEY-HERE", "YOUR-SECRET-KEY-HERE", true)
+ if err != nil {
+ log.Fatalln(err)
+ }
+
+ ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)
+ defer cancel()
+
+ opts := minio.GetObjectOptions{}
+ opts.SetModified(time.Now().Round(10 * time.Minute)) // get object if was modified within the last 10 minutes
+ reader, err := s3Client.GetObjectWithContext(ctx, "my-bucketname", "my-objectname", opts)
+ if err != nil {
+ log.Fatalln(err)
+ }
+ defer reader.Close()
+
+ localFile, err := os.Create("my-testfile")
+ if err != nil {
+ log.Fatalln(err)
+ }
+ defer localFile.Close()
+
+ stat, err := reader.Stat()
+ if err != nil {
+ log.Fatalln(err)
+ }
+
+ if _, err := io.CopyN(localFile, reader, stat.Size); err != nil {
+ log.Fatalln(err)
+ }
+}
diff --git a/examples/s3/getobject.go b/examples/s3/getobject.go
index 96bb855..e17ef81 100644
--- a/examples/s3/getobject.go
+++ b/examples/s3/getobject.go
@@ -1,7 +1,8 @@
// +build ignore
/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage (C) 2015 Minio, Inc.
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage
+ * Copyright 2015-2017 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,7 +41,7 @@ func main() {
log.Fatalln(err)
}
- reader, err := s3Client.GetObject("my-bucketname", "my-objectname")
+ reader, err := s3Client.GetObject("my-bucketname", "my-objectname", minio.GetObjectOptions{})
if err != nil {
log.Fatalln(err)
}
diff --git a/examples/s3/listbucketpolicies.go b/examples/s3/listbucketpolicies.go
index 19a2d1b..43edd0c 100644
--- a/examples/s3/listbucketpolicies.go
+++ b/examples/s3/listbucketpolicies.go
@@ -1,7 +1,8 @@
// +build ignore
/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage (C) 2015, 2016 Minio, Inc.
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage
+ * Copyright 2015-2017 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/examples/s3/listbuckets.go b/examples/s3/listbuckets.go
index 81a99e6..5eae587 100644
--- a/examples/s3/listbuckets.go
+++ b/examples/s3/listbuckets.go
@@ -1,7 +1,8 @@
// +build ignore
/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage (C) 2015 Minio, Inc.
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage
+ * Copyright 2015-2017 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/examples/s3/listincompleteuploads.go b/examples/s3/listincompleteuploads.go
index 34771e4..a5a79b6 100644
--- a/examples/s3/listincompleteuploads.go
+++ b/examples/s3/listincompleteuploads.go
@@ -1,7 +1,8 @@
// +build ignore
/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage (C) 2015 Minio, Inc.
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage
+ * Copyright 2015-2017 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/examples/s3/listobjects-N.go b/examples/s3/listobjects-N.go
index 5dde367..55bceb4 100644
--- a/examples/s3/listobjects-N.go
+++ b/examples/s3/listobjects-N.go
@@ -1,7 +1,8 @@
// +build ignore
/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage (C) 2015 Minio, Inc.
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage
+ * Copyright 2015-2017 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/examples/s3/listobjects.go b/examples/s3/listobjects.go
index 4fd5c06..1da2e3f 100644
--- a/examples/s3/listobjects.go
+++ b/examples/s3/listobjects.go
@@ -1,7 +1,8 @@
// +build ignore
/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage (C) 2015 Minio, Inc.
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage
+ * Copyright 2015-2017 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/examples/s3/listobjectsV2.go b/examples/s3/listobjectsV2.go
index b52b4da..190aec3 100644
--- a/examples/s3/listobjectsV2.go
+++ b/examples/s3/listobjectsV2.go
@@ -1,7 +1,8 @@
// +build ignore
/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage (C) 2016 Minio, Inc.
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage
+ * Copyright 2015-2017 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/examples/s3/makebucket.go b/examples/s3/makebucket.go
index ae222a8..419c96c 100644
--- a/examples/s3/makebucket.go
+++ b/examples/s3/makebucket.go
@@ -1,7 +1,8 @@
// +build ignore
/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage (C) 2015 Minio, Inc.
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage
+ * Copyright 2015-2017 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/examples/s3/presignedgetobject.go b/examples/s3/presignedgetobject.go
index 11be0c0..fd7fb9e 100644
--- a/examples/s3/presignedgetobject.go
+++ b/examples/s3/presignedgetobject.go
@@ -1,7 +1,8 @@
// +build ignore
/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage (C) 2015 Minio, Inc.
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage
+ * Copyright 2015-2017 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/examples/s3/presignedheadobject.go b/examples/s3/presignedheadobject.go
new file mode 100644
index 0000000..8dbc0a4
--- /dev/null
+++ b/examples/s3/presignedheadobject.go
@@ -0,0 +1,54 @@
+// +build ignore
+
+/*
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage
+ * Copyright 2015-2017 Minio, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package main
+
+import (
+ "log"
+ "net/url"
+ "time"
+
+ "github.com/minio/minio-go"
+)
+
+func main() {
+ // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-bucketname and my-objectname
+ // are dummy values, please replace them with original values.
+
+ // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
+ // This boolean value is the last argument for New().
+
+ // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
+ // determined based on the Endpoint value.
+ s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
+ if err != nil {
+ log.Fatalln(err)
+ }
+
+ // Set request parameters
+ reqParams := make(url.Values)
+ reqParams.Set("response-content-disposition", "attachment; filename=\"your-filename.txt\"")
+
+ // Gernerate presigned get object url.
+ presignedURL, err := s3Client.PresignedHeadObject("my-bucketname", "my-objectname", time.Duration(1000)*time.Second, reqParams)
+ if err != nil {
+ log.Fatalln(err)
+ }
+ log.Println(presignedURL)
+}
diff --git a/examples/s3/presignedpostpolicy.go b/examples/s3/presignedpostpolicy.go
index 3f37cef..205ac95 100644
--- a/examples/s3/presignedpostpolicy.go
+++ b/examples/s3/presignedpostpolicy.go
@@ -1,7 +1,8 @@
// +build ignore
/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage (C) 2015 Minio, Inc.
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage
+ * Copyright 2015-2017 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/examples/s3/presignedputobject.go b/examples/s3/presignedputobject.go
index 3db6f6e..b2f8b4f 100644
--- a/examples/s3/presignedputobject.go
+++ b/examples/s3/presignedputobject.go
@@ -1,7 +1,8 @@
// +build ignore
/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage (C) 2015 Minio, Inc.
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage
+ * Copyright 2015-2017 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/examples/s3/put-encrypted-object.go b/examples/s3/put-encrypted-object.go
index b8f7e12..cdf09ac 100644
--- a/examples/s3/put-encrypted-object.go
+++ b/examples/s3/put-encrypted-object.go
@@ -1,7 +1,8 @@
// +build ignore
/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage (C) 2015 Minio, Inc.
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage
+ * Copyright 2015-2017 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -75,7 +76,7 @@ func main() {
}
// Encrypt file content and upload to the server
- n, err := s3Client.PutEncryptedObject("my-bucketname", "my-objectname", file, cbcMaterials, nil, nil)
+ n, err := s3Client.PutEncryptedObject("my-bucketname", "my-objectname", file, cbcMaterials)
if err != nil {
log.Fatalln(err)
}
diff --git a/examples/s3/putobject-context.go b/examples/s3/putobject-context.go
new file mode 100644
index 0000000..acc923f
--- /dev/null
+++ b/examples/s3/putobject-context.go
@@ -0,0 +1,68 @@
+// +build ignore
+
+/*
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage
+ * Copyright 2017 Minio, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package main
+
+import (
+ "log"
+ "os"
+ "time"
+
+ "context"
+
+ "github.com/minio/minio-go"
+)
+
+func main() {
+ // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-testfile, my-bucketname and
+ // my-objectname are dummy values, please replace them with original values.
+
+ // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
+ // This boolean value is the last argument for New().
+
+ // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
+ // determined based on the Endpoint value.
+
+ s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
+ if err != nil {
+ log.Fatalln(err)
+ }
+
+ ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)
+ defer cancel()
+
+ object, err := os.Open("my-testfile")
+ if err != nil {
+ log.Fatalln(err)
+ }
+ defer object.Close()
+
+ objectStat, err := object.Stat()
+ if err != nil {
+ log.Fatalln(err)
+ }
+
+ n, err := s3Client.PutObjectWithContext(ctx, "my-bucketname", "my-objectname", object, objectStat.Size(), minio.PutObjectOptions{
+ ContentType: "application/octet-stream",
+ })
+ if err != nil {
+ log.Fatalln(err)
+ }
+ log.Println("Uploaded", "my-objectname", " of size: ", n, "Successfully.")
+}
diff --git a/examples/s3/putobject-getobject-sse.go b/examples/s3/putobject-getobject-sse.go
index 92e6a48..3d3b2fd 100644
--- a/examples/s3/putobject-getobject-sse.go
+++ b/examples/s3/putobject-getobject-sse.go
@@ -1,7 +1,8 @@
// +build ignore
/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage (C) 2017 Minio, Inc.
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage
+ * Copyright 2017 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,7 +25,6 @@ import (
"encoding/base64"
"io/ioutil"
"log"
- "net/http"
minio "github.com/minio/minio-go"
)
@@ -54,24 +54,24 @@ func main() {
// of the encryption key or to decrypt the contents of the
// encrypted object. That means, if you lose the encryption
// key, you lose the object.
- var metadata = map[string][]string{
- "x-amz-server-side-encryption-customer-algorithm": []string{"AES256"},
- "x-amz-server-side-encryption-customer-key": []string{encryptionKey},
- "x-amz-server-side-encryption-customer-key-MD5": []string{encryptionKeyMD5},
+ var metadata = map[string]string{
+ "x-amz-server-side-encryption-customer-algorithm": "AES256",
+ "x-amz-server-side-encryption-customer-key": encryptionKey,
+ "x-amz-server-side-encryption-customer-key-MD5": encryptionKeyMD5,
}
// minioClient.TraceOn(os.Stderr) // Enable to debug.
- _, err = minioClient.PutObjectWithMetadata("mybucket", "my-encrypted-object.txt", content, metadata, nil)
+ _, err = minioClient.PutObject("mybucket", "my-encrypted-object.txt", content, 11, minio.PutObjectOptions{UserMetadata: metadata})
if err != nil {
log.Fatalln(err)
}
- var reqHeaders = minio.RequestHeaders{Header: http.Header{}}
+ opts := minio.GetObjectOptions{}
for k, v := range metadata {
- reqHeaders.Set(k, v[0])
+ opts.Set(k, v)
}
coreClient := minio.Core{minioClient}
- reader, _, err := coreClient.GetObject("mybucket", "my-encrypted-object.txt", reqHeaders)
+ reader, _, err := coreClient.GetObject("mybucket", "my-encrypted-object.txt", opts)
if err != nil {
log.Fatalln(err)
}
diff --git a/examples/s3/putobject-progress.go b/examples/s3/putobject-progress.go
index 1179fd7..0e92dd6 100644
--- a/examples/s3/putobject-progress.go
+++ b/examples/s3/putobject-progress.go
@@ -1,7 +1,8 @@
// +build ignore
/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage (C) 2015 Minio, Inc.
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage
+ * Copyright 2015-2017 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,7 +40,7 @@ func main() {
log.Fatalln(err)
}
- reader, err := s3Client.GetObject("my-bucketname", "my-objectname")
+ reader, err := s3Client.GetObject("my-bucketname", "my-objectname", minio.GetObjectOptions{})
if err != nil {
log.Fatalln(err)
}
@@ -54,8 +55,8 @@ func main() {
// the Reads inside.
progress := pb.New64(objectInfo.Size)
progress.Start()
+ n, err := s3Client.PutObject("my-bucketname", "my-objectname-progress", reader, objectInfo.Size, minio.PutObjectOptions{ContentType: "application/octet-stream", Progress: progress})
- n, err := s3Client.PutObjectWithProgress("my-bucketname", "my-objectname-progress", reader, "application/octet-stream", progress)
if err != nil {
log.Fatalln(err)
}
diff --git a/examples/s3/putobject-s3-accelerate.go b/examples/s3/putobject-s3-accelerate.go
index e47976f..06345cd 100644
--- a/examples/s3/putobject-s3-accelerate.go
+++ b/examples/s3/putobject-s3-accelerate.go
@@ -1,7 +1,8 @@
// +build ignore
/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage (C) 2016 Minio, Inc.
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage
+ * Copyright 2015-2017 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,7 +41,7 @@ func main() {
}
// Enable S3 transfer accelerate endpoint.
- s3Client.S3TransferAccelerate("s3-accelerate.amazonaws.com")
+ s3Client.SetS3TransferAccelerate("s3-accelerate.amazonaws.com")
object, err := os.Open("my-testfile")
if err != nil {
@@ -48,7 +49,12 @@ func main() {
}
defer object.Close()
- n, err := s3Client.PutObject("my-bucketname", "my-objectname", object, "application/octet-stream")
+ objectStat, err := object.Stat()
+ if err != nil {
+ log.Fatalln(err)
+ }
+
+ n, err := s3Client.PutObject("my-bucketname", "my-objectname", object, objectStat.Size(), minio.PutObjectOptions{ContentType: "application/octet-stream"})
if err != nil {
log.Fatalln(err)
}
diff --git a/examples/s3/putobject-streaming.go b/examples/s3/putobject-streaming.go
index d10407d..85b78dd 100644
--- a/examples/s3/putobject-streaming.go
+++ b/examples/s3/putobject-streaming.go
@@ -1,7 +1,8 @@
// +build ignore
/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage (C) 2016 Minio, Inc.
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage
+ * Copyright 2015-2017 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -45,7 +46,7 @@ func main() {
}
defer object.Close()
- n, err := s3Client.PutObjectStreaming("my-bucketname", "my-objectname", object)
+ n, err := s3Client.PutObject("my-bucketname", "my-objectname", object, -1, minio.PutObjectOptions{})
if err != nil {
log.Fatalln(err)
}
diff --git a/examples/s3/putobject.go b/examples/s3/putobject.go
index caa7313..b9e4ff1 100644
--- a/examples/s3/putobject.go
+++ b/examples/s3/putobject.go
@@ -1,7 +1,8 @@
// +build ignore
/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage (C) 2015 Minio, Inc.
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage
+ * Copyright 2015-2017 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,8 +45,12 @@ func main() {
log.Fatalln(err)
}
defer object.Close()
+ objectStat, err := object.Stat()
+ if err != nil {
+ log.Fatalln(err)
+ }
- n, err := s3Client.PutObject("my-bucketname", "my-objectname", object, "application/octet-stream")
+ n, err := s3Client.PutObject("my-bucketname", "my-objectname", object, objectStat.Size(), minio.PutObjectOptions{ContentType: "application/octet-stream"})
if err != nil {
log.Fatalln(err)
}
diff --git a/examples/s3/removeallbucketnotification.go b/examples/s3/removeallbucketnotification.go
index 0f5f3a7..1186afa 100644
--- a/examples/s3/removeallbucketnotification.go
+++ b/examples/s3/removeallbucketnotification.go
@@ -1,7 +1,8 @@
// +build ignore
/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage (C) 2015, 2016 Minio, Inc.
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage
+ * Copyright 2015-2017 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/examples/s3/removebucket.go b/examples/s3/removebucket.go
index fb013ca..7a7737e 100644
--- a/examples/s3/removebucket.go
+++ b/examples/s3/removebucket.go
@@ -1,7 +1,8 @@
// +build ignore
/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage (C) 2015 Minio, Inc.
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage
+ * Copyright 2015-2017 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/examples/s3/removeincompleteupload.go b/examples/s3/removeincompleteupload.go
index d486182..31cc879 100644
--- a/examples/s3/removeincompleteupload.go
+++ b/examples/s3/removeincompleteupload.go
@@ -1,7 +1,8 @@
// +build ignore
/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage (C) 2015 Minio, Inc.
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage
+ * Copyright 2015-2017 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/examples/s3/removeobject.go b/examples/s3/removeobject.go
index 13b00b4..7e58485 100644
--- a/examples/s3/removeobject.go
+++ b/examples/s3/removeobject.go
@@ -1,7 +1,8 @@
// +build ignore
/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage (C) 2015 Minio, Inc.
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage
+ * Copyright 2015-2017 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/examples/s3/removeobjects.go b/examples/s3/removeobjects.go
index 5946069..b912bc8 100644
--- a/examples/s3/removeobjects.go
+++ b/examples/s3/removeobjects.go
@@ -1,7 +1,8 @@
// +build ignore
/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage (C) 2015 Minio, Inc.
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage
+ * Copyright 2015-2017 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +21,6 @@ package main
import (
"log"
- "strconv"
"github.com/minio/minio-go"
)
@@ -44,8 +44,12 @@ func main() {
// Send object names that are needed to be removed to objectsCh
go func() {
defer close(objectsCh)
- for i := 0; i < 10; i++ {
- objectsCh <- "/path/to/my-objectname" + strconv.Itoa(i)
+ // List all objects from a bucket-name with a matching prefix.
+ for object := range s3Client.ListObjects("my-bucketname", "my-prefixname", true, doneCh) {
+ if object.Err != nil {
+ log.Fatalln(object.Err)
+ }
+ objectsCh <- object.Key
}
}()
diff --git a/examples/s3/setbucketnotification.go b/examples/s3/setbucketnotification.go
index 5fe1e31..b5af30f 100644
--- a/examples/s3/setbucketnotification.go
+++ b/examples/s3/setbucketnotification.go
@@ -1,7 +1,8 @@
// +build ignore
/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage (C) 2015, 2016 Minio, Inc.
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage
+ * Copyright 2015-2017 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/examples/s3/setbucketpolicy.go b/examples/s3/setbucketpolicy.go
index 40906ee..c81fb50 100644
--- a/examples/s3/setbucketpolicy.go
+++ b/examples/s3/setbucketpolicy.go
@@ -1,7 +1,8 @@
// +build ignore
/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage (C) 2015, 2016 Minio, Inc.
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage
+ * Copyright 2015-2017 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/examples/s3/statobject.go b/examples/s3/statobject.go
index 4c5453a..0b27a83 100644
--- a/examples/s3/statobject.go
+++ b/examples/s3/statobject.go
@@ -1,7 +1,8 @@
// +build ignore
/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage (C) 2015 Minio, Inc.
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage
+ * Copyright 2015-2017 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,7 +38,7 @@ func main() {
if err != nil {
log.Fatalln(err)
}
- stat, err := s3Client.StatObject("my-bucketname", "my-objectname")
+ stat, err := s3Client.StatObject("my-bucketname", "my-objectname", minio.StatObjectOptions{})
if err != nil {
log.Fatalln(err)
}