Vendorize latest minio-go (#4989)
As minio-go behavior is fixed to treat empty byte arrays and nil byte arrays in the same manner. These changes are needed in minio to address the PutObject failure for S3 Gateway. Fixes: https://github.com/minio/minio/issues/4974, https://github.com/minio/minio-java/issues/615master
parent
a5fbe1e16c
commit
789270af3c
@ -0,0 +1,24 @@ |
||||
/* |
||||
* Minio Go Library for Amazon S3 Compatible Cloud Storage (C) 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 minio |
||||
|
||||
import "context" |
||||
|
||||
// GetObjectWithContext - returns an seekable, readable object.
|
||||
func (c Client) GetObjectWithContext(ctx context.Context, bucketName, objectName string) (*Object, error) { |
||||
return c.getObjectWithContext(ctx, bucketName, objectName) |
||||
} |
@ -0,0 +1,38 @@ |
||||
/* |
||||
* Minio Go Library for Amazon S3 Compatible Cloud Storage (C) 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 minio |
||||
|
||||
import ( |
||||
"context" |
||||
"io" |
||||
) |
||||
|
||||
// PutObjectWithContext - Identical to PutObject call, but accepts context to facilitate request cancellation.
|
||||
func (c Client) PutObjectWithContext(ctx context.Context, bucketName, objectName string, reader io.Reader, objectSize int64, |
||||
opts PutObjectOptions) (n int64, err error) { |
||||
err = opts.validate() |
||||
if err != nil { |
||||
return 0, err |
||||
} |
||||
if opts.EncryptMaterials != nil { |
||||
if err = opts.EncryptMaterials.SetupEncryptMode(reader); err != nil { |
||||
return 0, err |
||||
} |
||||
return c.putObjectMultipartStreamNoLength(ctx, bucketName, objectName, opts.EncryptMaterials, opts) |
||||
} |
||||
return c.putObjectCommon(ctx, bucketName, objectName, reader, objectSize, opts) |
||||
} |
@ -0,0 +1,63 @@ |
||||
/* |
||||
* Minio Go Library for Amazon S3 Compatible Cloud Storage (C) 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 minio |
||||
|
||||
import ( |
||||
"context" |
||||
"mime" |
||||
"os" |
||||
"path/filepath" |
||||
|
||||
"github.com/minio/minio-go/pkg/s3utils" |
||||
) |
||||
|
||||
// FPutObjectWithContext - Create an object in a bucket, with contents from file at filePath. Allows request cancellation.
|
||||
func (c Client) FPutObjectWithContext(ctx context.Context, bucketName, objectName, filePath string, opts PutObjectOptions) (n int64, err error) { |
||||
// Input validation.
|
||||
if err := s3utils.CheckValidBucketName(bucketName); err != nil { |
||||
return 0, err |
||||
} |
||||
if err := s3utils.CheckValidObjectName(objectName); err != nil { |
||||
return 0, err |
||||
} |
||||
|
||||
// Open the referenced file.
|
||||
fileReader, err := os.Open(filePath) |
||||
// If any error fail quickly here.
|
||||
if err != nil { |
||||
return 0, err |
||||
} |
||||
defer fileReader.Close() |
||||
|
||||
// Save the file stat.
|
||||
fileStat, err := fileReader.Stat() |
||||
if err != nil { |
||||
return 0, err |
||||
} |
||||
|
||||
// Save the file size.
|
||||
fileSize := fileStat.Size() |
||||
|
||||
// Set contentType based on filepath extension if not given or default
|
||||
// value of "application/octet-stream" if the extension has no associated type.
|
||||
if opts.ContentType == "" { |
||||
if opts.ContentType = mime.TypeByExtension(filepath.Ext(filePath)); opts.ContentType == "" { |
||||
opts.ContentType = "application/octet-stream" |
||||
} |
||||
} |
||||
return c.PutObjectWithContext(ctx, bucketName, objectName, fileReader, fileSize, opts) |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -1,39 +0,0 @@ |
||||
// +build go1.5,!go1.6,!go1.7,!go1.8
|
||||
|
||||
/* |
||||
* Minio Go Library for Amazon S3 Compatible Cloud Storage |
||||
* (C) 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 minio |
||||
|
||||
import ( |
||||
"net/http" |
||||
"time" |
||||
) |
||||
|
||||
// This default transport is similar to http.DefaultTransport
|
||||
// but with additional DisableCompression:
|
||||
var defaultMinioTransport http.RoundTripper = &http.Transport{ |
||||
Proxy: http.ProxyFromEnvironment, |
||||
TLSHandshakeTimeout: 10 * time.Second, |
||||
// Set this value so that the underlying transport round-tripper
|
||||
// doesn't try to auto decode the body of objects with
|
||||
// content-encoding set to `gzip`.
|
||||
//
|
||||
// Refer:
|
||||
// https://golang.org/src/net/http/transport.go?h=roundTrip#L1843
|
||||
DisableCompression: true, |
||||
} |
@ -1,40 +0,0 @@ |
||||
// +build go1.6,!go1.7,!go1.8
|
||||
|
||||
/* |
||||
* Minio Go Library for Amazon S3 Compatible Cloud Storage |
||||
* (C) 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 minio |
||||
|
||||
import ( |
||||
"net/http" |
||||
"time" |
||||
) |
||||
|
||||
// This default transport is similar to http.DefaultTransport
|
||||
// but with additional DisableCompression:
|
||||
var defaultMinioTransport http.RoundTripper = &http.Transport{ |
||||
Proxy: http.ProxyFromEnvironment, |
||||
TLSHandshakeTimeout: 10 * time.Second, |
||||
ExpectContinueTimeout: 1 * time.Second, |
||||
// Set this value so that the underlying transport round-tripper
|
||||
// doesn't try to auto decode the body of objects with
|
||||
// content-encoding set to `gzip`.
|
||||
//
|
||||
// Refer:
|
||||
// https://golang.org/src/net/http/transport.go?h=roundTrip#L1843
|
||||
DisableCompression: true, |
||||
} |
Loading…
Reference in new issue