diff --git a/cmd/fs-v1.go b/cmd/fs-v1.go index 43fa39477..e24af39c5 100644 --- a/cmd/fs-v1.go +++ b/cmd/fs-v1.go @@ -450,6 +450,11 @@ func (fs *FSObjects) CopyObject(ctx context.Context, srcBucket, srcObject, dstBu // Return the new object info. return fsMeta.ToObjectInfo(srcBucket, srcObject, fi), nil } + + if err := checkPutObjectArgs(ctx, dstBucket, dstObject, fs, srcInfo.PutObjReader.Size()); err != nil { + return ObjectInfo{}, err + } + objInfo, err := fs.putObject(ctx, dstBucket, dstObject, srcInfo.PutObjReader, ObjectOptions{ServerSideEncryption: dstOpts.ServerSideEncryption, UserDefined: srcInfo.UserDefined}) if err != nil { return oi, toObjectErr(err, dstBucket, dstObject) @@ -813,6 +818,7 @@ func (fs *FSObjects) PutObject(ctx context.Context, bucket string, object string return objInfo, err } defer objectLock.Unlock() + return fs.putObject(ctx, bucket, object, r, opts) } @@ -854,10 +860,6 @@ func (fs *FSObjects) putObject(ctx context.Context, bucket string, object string return fsMeta.ToObjectInfo(bucket, object, fi), nil } - if err = checkPutObjectArgs(ctx, bucket, object, fs, data.Size()); err != nil { - return ObjectInfo{}, err - } - // Check if an object is present as one of the parent dir. if fs.parentDirIsObject(ctx, bucket, path.Dir(object)) { return ObjectInfo{}, toObjectErr(errFileParentIsFile, bucket, object) diff --git a/cmd/xl-v1-object.go b/cmd/xl-v1-object.go index fad672143..1979c57d1 100644 --- a/cmd/xl-v1-object.go +++ b/cmd/xl-v1-object.go @@ -116,7 +116,7 @@ func (xl xlObjects) CopyObject(ctx context.Context, srcBucket, srcObject, dstBuc } putOpts := ObjectOptions{ServerSideEncryption: dstOpts.ServerSideEncryption, UserDefined: srcInfo.UserDefined} - return xl.putObject(ctx, dstBucket, dstObject, srcInfo.PutObjReader, putOpts) + return xl.PutObject(ctx, dstBucket, dstObject, srcInfo.PutObjReader, putOpts) } // GetObjectNInfo - returns object info and an object @@ -510,6 +510,7 @@ func (xl xlObjects) PutObject(ctx context.Context, bucket string, object string, return objInfo, err } defer objectLock.Unlock() + return xl.putObject(ctx, bucket, object, data, opts) } @@ -560,11 +561,6 @@ func (xl xlObjects) putObject(ctx context.Context, bucket string, object string, return dirObjectInfo(bucket, object, data.Size(), opts.UserDefined), nil } - // Validate put object input args. - if err = checkPutObjectArgs(ctx, bucket, object, xl, data.Size()); err != nil { - return ObjectInfo{}, err - } - // Validate input data size and it can never be less than zero. if data.Size() < -1 { logger.LogIf(ctx, errInvalidArgument)