Add the comment to declare the out of memory issue when put large local file
This commit is contained in:
@@ -26,7 +26,7 @@ func main() {
|
|||||||
RequestHeader: true,
|
RequestHeader: true,
|
||||||
RequestBody: true,
|
RequestBody: true,
|
||||||
ResponseHeader: true,
|
ResponseHeader: true,
|
||||||
ResponseBody: true,
|
ResponseBody: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -20,8 +20,9 @@ func main() {
|
|||||||
SecretID: os.Getenv("COS_SECRETID"),
|
SecretID: os.Getenv("COS_SECRETID"),
|
||||||
SecretKey: os.Getenv("COS_SECRETKEY"),
|
SecretKey: os.Getenv("COS_SECRETKEY"),
|
||||||
Transport: &debug.DebugRequestTransport{
|
Transport: &debug.DebugRequestTransport{
|
||||||
RequestHeader: true,
|
RequestHeader: true,
|
||||||
RequestBody: true,
|
// Notice when put a large file and set need the request body, might happend out of memory error.
|
||||||
|
RequestBody: false,
|
||||||
ResponseHeader: true,
|
ResponseHeader: true,
|
||||||
ResponseBody: true,
|
ResponseBody: true,
|
||||||
},
|
},
|
||||||
@@ -54,4 +55,10 @@ func main() {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Case3 put object by local file path
|
||||||
|
_, err = c.Object.PutFromFile(context.Background(), name, "./test", nil)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
18
object.go
18
object.go
@@ -105,17 +105,17 @@ func (s *ObjectService) Put(ctx context.Context, name string, r io.Reader, opt *
|
|||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Not Suggest use for now, need to improve
|
|
||||||
// PutFromFile put object from local file
|
// PutFromFile put object from local file
|
||||||
// func (s *ObjectService) PutFromFile(ctx context.Context, name string, filePath string, opt *ObjectPutOptions) (*Response, error) {
|
// Notice that when use this put large file need set non-body of debug req/resp, otherwise will out of memory
|
||||||
// fd, err := os.Open(filePath)
|
func (s *ObjectService) PutFromFile(ctx context.Context, name string, filePath string, opt *ObjectPutOptions) (*Response, error) {
|
||||||
// if err != nil {
|
fd, err := os.Open(filePath)
|
||||||
// return nil, err
|
if err != nil {
|
||||||
// }
|
return nil, err
|
||||||
// defer fd.Close()
|
}
|
||||||
|
defer fd.Close()
|
||||||
|
|
||||||
// return s.Put(ctx, name, fd, opt)
|
return s.Put(ctx, name, fd, opt)
|
||||||
// }
|
}
|
||||||
|
|
||||||
// ObjectCopyHeaderOptions is the head option of the Copy
|
// ObjectCopyHeaderOptions is the head option of the Copy
|
||||||
type ObjectCopyHeaderOptions struct {
|
type ObjectCopyHeaderOptions struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user