0026-00000002

更新时间:
复制 MD 格式

Problem description

The object already exists.

Causes

You sent a PutObject or CopyObject request with x-oss-forbid-overwrite: true, and an object with the same name already exists in the bucket.

By default, PutObject and CopyObject overwrite an existing object if the names match. Setting x-oss-forbid-overwrite: true disables this behavior — OSS returns HTTP 409 instead of overwriting.

Examples

The following request triggers this error:

PUT /object-exist.txt HTTP/1.1
Content-Length: ContentLength
Content-Type: ContentType
Host: examplebucket.oss-cn-hangzhou.aliyuncs.com
Date: GMT Date
Authorization: SignatureValue
x-oss-forbid-overwrite: true

Because object-exist.txt already exists in examplebucket and x-oss-forbid-overwrite is set to true, OSS returns HTTP 409 with the FileAlreadyExists error.

Solutions

Choose the approach that fits your use case:

  • Check whether the object exists first — Call HeadObject. A 404 response means the object does not exist and the write will succeed.

  • Allow overwriting — Remove the x-oss-forbid-overwrite header from your request, or set it to false. OSS overwrites the existing object.

  • Keep both the new and existing objects — Enable versioning on the bucket. See Enable versioning.

References