- err := b.Bucket.PutReader(path, NewCountingReader(r, b.stats.TickOutBytes), length, contType, perm, options)
- b.stats.Tick(&b.stats.Ops, &b.stats.PutOps)
- b.stats.TickErr(err)
- return err
-}
-
-func (b *s3bucket) Put(path string, data []byte, contType string, perm s3.ACL, options s3.Options) error {
- var reader io.ReadCloser
- // goamz will only send Content-Length: 0 when io.Reader is nil due to net.http.Request.ContentLength
- // behavior. otherwise, Content-Length header is omitted which will cause some S3-like services (such
- // as Ceph RadosGW) to fail to create empty objects
- if data != nil {
- reader = NewCountingReader(bytes.NewBuffer(data), b.stats.TickOutBytes)
+ if length == 0 {
+ // goamz will only send Content-Length: 0 when reader
+ // is nil due to net.http.Request.ContentLength
+ // behavior. Otherwise, Content-Length header is
+ // omitted which will cause some S3 services
+ // (including AWS and Ceph RadosGW) to fail to create
+ // empty objects.
+ r = nil
+ } else {
+ r = NewCountingReader(r, b.stats.TickOutBytes)