This looks wrong to me. When the object already exists, you must overwrite its content, not return the length of the existing file