pipe: Avoid double copy of buffers in minio-go
Disallows multiple copies being referenced internally leads to OOM conditions on certain low memory devices and systems. Fixes #1641
This commit is contained in:
+1
-1
@@ -157,7 +157,7 @@ __Arguments__
|
||||
|
||||
__Example__
|
||||
```go
|
||||
err := s3Client.SetBucketPolicy("mybucket", "myprefix", "readwrite")
|
||||
err := s3Client.SetBucketPolicy("mybucket", "myprefix", BucketPolicyReadWrite)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
|
||||
+10
@@ -21,7 +21,9 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"mime"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
)
|
||||
|
||||
@@ -57,6 +59,14 @@ func (c Client) FPutObject(bucketName, objectName, filePath, contentType string)
|
||||
return 0, ErrEntityTooLarge(fileSize, maxMultipartPutObjectSize, bucketName, objectName)
|
||||
}
|
||||
|
||||
// Set contentType based on filepath extension if not given or default
|
||||
// value of "binary/octet-stream" if the extension has no associated type.
|
||||
if contentType == "" {
|
||||
if contentType = mime.TypeByExtension(filepath.Ext(filePath)); contentType == "" {
|
||||
contentType = "application/octet-stream"
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: Google Cloud Storage multipart Put is not compatible with Amazon S3 APIs.
|
||||
// Current implementation will only upload a maximum of 5GiB to Google Cloud Storage servers.
|
||||
if isGoogleEndpoint(c.endpointURL) {
|
||||
|
||||
+1
-1
@@ -124,7 +124,7 @@ func (c Client) putObjectMultipartStream(bucketName, objectName string, reader i
|
||||
var reader io.Reader
|
||||
// Update progress reader appropriately to the latest offset
|
||||
// as we read from the source.
|
||||
reader = newHook(bytes.NewReader(tmpBuffer.Bytes()), progress)
|
||||
reader = newHook(tmpBuffer, progress)
|
||||
|
||||
// Verify if part should be uploaded.
|
||||
if shouldUploadPart(objectPart{
|
||||
|
||||
+1
-1
@@ -155,7 +155,7 @@ func (c Client) putObjectMultipartFromReadAt(bucketName, objectName string, read
|
||||
var reader io.Reader
|
||||
// Update progress reader appropriately to the latest offset
|
||||
// as we read from the source.
|
||||
reader = newHook(bytes.NewReader(tmpBuffer.Bytes()), progress)
|
||||
reader = newHook(tmpBuffer, progress)
|
||||
|
||||
// Proceed to upload the part.
|
||||
var objPart objectPart
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ type Client struct {
|
||||
// Global constants.
|
||||
const (
|
||||
libraryName = "minio-go"
|
||||
libraryVersion = "1.0.0"
|
||||
libraryVersion = "1.0.1"
|
||||
)
|
||||
|
||||
// User Agent should always following the below style.
|
||||
|
||||
Vendored
+2
-2
@@ -39,8 +39,8 @@
|
||||
},
|
||||
{
|
||||
"path": "github.com/minio/minio-go",
|
||||
"revision": "ec610a695d37f1f04b9516a91857bfca007e3740",
|
||||
"revisionTime": "2016-03-19T15:53:30-07:00"
|
||||
"revision": "5a338968f406d8351e55c0d66cc754613ab9a206",
|
||||
"revisionTime": "2016-03-25T17:35:39-07:00"
|
||||
},
|
||||
{
|
||||
"path": "github.com/minio/minio/pkg/atomic",
|
||||
|
||||
Reference in New Issue
Block a user