summaryrefslogtreecommitdiff
path: root/api-put-object.go
diff options
context:
space:
mode:
Diffstat (limited to 'api-put-object.go')
-rw-r--r--api-put-object.go43
1 files changed, 33 insertions, 10 deletions
diff --git a/api-put-object.go b/api-put-object.go
index 0330cd9..bc0848b 100644
--- a/api-put-object.go
+++ b/api-put-object.go
@@ -1,6 +1,6 @@
/*
- * Minio Go Library for Amazon S3 Compatible Cloud Storage
- * Copyright 2015-2017 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.
@@ -25,9 +25,10 @@ import (
"net/http"
"runtime/debug"
"sort"
+ "time"
- "github.com/minio/minio-go/pkg/encrypt"
- "github.com/minio/minio-go/pkg/s3utils"
+ "github.com/minio/minio-go/v6/pkg/encrypt"
+ "github.com/minio/minio-go/v6/pkg/s3utils"
"golang.org/x/net/http/httpguts"
)
@@ -40,10 +41,13 @@ type PutObjectOptions struct {
ContentDisposition string
ContentLanguage string
CacheControl string
+ Mode *RetentionMode
+ RetainUntilDate *time.Time
ServerSideEncryption encrypt.ServerSide
NumThreads uint
StorageClass string
WebsiteRedirectLocation string
+ PartSize uint64
}
// getNumThreads - gets the number of threads to be used in the multipart
@@ -79,6 +83,14 @@ func (opts PutObjectOptions) Header() (header http.Header) {
if opts.CacheControl != "" {
header["Cache-Control"] = []string{opts.CacheControl}
}
+
+ if opts.Mode != nil {
+ header["x-amz-object-lock-mode"] = []string{opts.Mode.String()}
+ }
+ if opts.RetainUntilDate != nil {
+ header["x-amz-object-lock-retain-until-date"] = []string{opts.RetainUntilDate.Format(time.RFC3339)}
+ }
+
if opts.ServerSideEncryption != nil {
opts.ServerSideEncryption.Marshal(header)
}
@@ -108,6 +120,11 @@ func (opts PutObjectOptions) validate() (err error) {
return ErrInvalidArgument(v + " unsupported user defined metadata value")
}
}
+ if opts.Mode != nil {
+ if !opts.Mode.IsValid() {
+ return ErrInvalidArgument(opts.Mode.String() + " unsupported retention mode")
+ }
+ }
return nil
}
@@ -123,9 +140,9 @@ func (a completedParts) Less(i, j int) bool { return a[i].PartNumber < a[j].Part
//
// You must have WRITE permissions on a bucket to create an object.
//
-// - For size smaller than 64MiB PutObject automatically does a
+// - For size smaller than 128MiB PutObject automatically does a
// single atomic Put operation.
-// - For size larger than 64MiB PutObject automatically does a
+// - For size larger than 128MiB PutObject automatically does a
// multipart Put operation.
// - For size input as -1 PutObject does a multipart Put operation
// until input stream reaches EOF. Maximum object size that can
@@ -147,8 +164,13 @@ func (c Client) putObjectCommon(ctx context.Context, bucketName, objectName stri
return c.putObjectNoChecksum(ctx, bucketName, objectName, reader, size, opts)
}
+ partSize := opts.PartSize
+ if opts.PartSize == 0 {
+ partSize = minPartSize
+ }
+
if c.overrideSignerType.IsV2() {
- if size >= 0 && size < minPartSize {
+ if size >= 0 && size < int64(partSize) {
return c.putObjectNoChecksum(ctx, bucketName, objectName, reader, size, opts)
}
return c.putObjectMultipart(ctx, bucketName, objectName, reader, size, opts)
@@ -157,10 +179,11 @@ func (c Client) putObjectCommon(ctx context.Context, bucketName, objectName stri
return c.putObjectMultipartStreamNoLength(ctx, bucketName, objectName, reader, opts)
}
- if size < minPartSize {
+ if size < int64(partSize) {
return c.putObjectNoChecksum(ctx, bucketName, objectName, reader, size, opts)
}
- // For all sizes greater than 64MiB do multipart.
+
+ // For all sizes greater than 128MiB do multipart.
return c.putObjectMultipartStream(ctx, bucketName, objectName, reader, size, opts)
}
@@ -181,7 +204,7 @@ func (c Client) putObjectMultipartStreamNoLength(ctx context.Context, bucketName
var complMultipartUpload completeMultipartUpload
// Calculate the optimal parts info for a given size.
- totalPartsCount, partSize, _, err := optimalPartInfo(-1)
+ totalPartsCount, partSize, _, err := optimalPartInfo(-1, opts.PartSize)
if err != nil {
return 0, err
}