[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-18。"],[],[],null,["# Composite objects\n\n[Create](/storage/docs/composing-objects)\n\nThis page describes composite objects, which you create from existing objects\nwithout transferring additional object data. Composite objects are useful for\nmaking [appends to an existing object](#appends), as well as for recreating\nobjects that you [uploaded as multiple components in parallel](/storage/docs/parallel-composite-uploads).\n\nCompose operation\n-----------------\n\nThe compose operation concatenates the data in a given sequence of source\nobjects to create a new object called a *composite object*. The source objects\nall must:\n\n- Have the same [storage class](/storage/docs/storage-classes).\n- Be stored in the same Cloud Storage bucket.\n\nWhen you perform a composition:\n\n- The source objects are unaffected.\n- You can use between 1 and 32 source objects.\n- Source objects can themselves be composite objects.\n\nThe composite object that results from a composition:\n\n- Has the same storage class as the source objects.\n- Does not change if the source objects are subsequently replaced or deleted.\n\nWhen using [`gcloud storage`](/sdk/gcloud/reference/storage) to perform object composition, the object that\nresults has a [`Content-Type`](/storage/docs/metadata#content-type) set to match the `Content-Type` of the first\nsource object.\n\nComposite object metadata\n-------------------------\n\nThere are several differences between the metadata of a composite object and\nthe metadata of other objects:\n\n- Composite objects *do not* have an MD5 hash metadata field.\n\n- The ETag value of a composite object is not based on an MD5 hash, and client\n code should make no assumptions about composite object ETags except that\n they change whenever the underlying object changes per the\n [IETF specification for HTTP/1.1](https://datatracker.ietf.org/doc/html/rfc7232#section-2.3).\n\n | **Caution:** Exercise caution when first using composite objects, since any clients expecting to find an MD5 digest within the ETag header may conclude that object data has been corrupted, which could trigger endless data retransmission attempts.\n- Each composite object has a *component count* metadata field, which counts the\n number of non-composite objects contained within the composite object.\n\n - If you rewrite a composite object to a different location or storage class, the result is a composite object with a component count of 1.\n\nIntegrity Checking Composite Objects\n------------------------------------\n\nCloud Storage uses [CRC32C](https://datatracker.ietf.org/doc/html/rfc4960#appendix-B) for integrity checking each\nsource object at upload time and for allowing the caller to perform an integrity\ncheck of the resulting composite object when it is downloaded. CRC32C is an\nerror detecting code that can be efficiently calculated from the CRC32C\nvalues of its components. Your application should use CRC32C as follows:\n\n- When uploading source objects, you should calculate the CRC32C for each object using a CRC32C library, such as one of those listed in the [Object metadata page](/storage/docs/metadata#crc32c), and include that value in your request. Based on the values you provide, Cloud Storage [validates each upload](/storage/docs/data-validation).\n- The compose operation automatically checks that the source objects are correctly assembled, and it ignores any CRC32C value you provide as part of the compose request. A CRC32C of the resulting composite object is returned in the response.\n- If your application could change source objects between the time of uploading and composing those objects, you should specify generation-specific names for the source objects to avoid race conditions. Alternatively, you can build a CRC32C value from the CRC32C values of the intended source objects and compare it to the CRC32C value returned by the compose operation.\n- At download time, you should calculate the CRC32C of the downloaded object and compare that with the value included in the response.\n\n| **Note:** CRC32C is not intended to protect against [\"man-in-the-middle\"](https://en.wikipedia.org/wiki/Man-in-the-middle_attack) attacks, where someone modifies the content in a way that still matches the provided checksum. Protection against such attacks is provided by using SSL connections when uploading and downloading objects, which is the default for many tools and libraries, such as the Google Cloud CLI.\n\nLimited Append and Edit\n-----------------------\n\nYou can use the compose operation to perform limited object appends and edits.\n\nYou accomplish appending by uploading data to a temporary new object, composing\nthe object you wish to append with this temporary object, optionally naming the\noutput of the compose operation the same as the original object, and deleting\nthe temporary object.\n\nFor example, in the [gcloud CLI](/sdk/gcloud), the series of commands to\nappend the string `new data` to an existing Cloud Storage object is\nthe following: \n\n```\n$ echo 'new data' | gcloud storage cp - gs://bucket/temporary_object\n$ gcloud storage objects compose gs://bucket/object_to_append gs://bucket/temporary_object \\\n gs://bucket/object_to_append\n$ gcloud storage rm gs://bucket/temporary_object\n```\n\nYou can also use composition to support a basic flavor of object editing.\nFor example, you could compose an object *X* from the sequence *{Y1, Y2, Y3}* ,\nreplace the contents of *Y2* , and recompose *X* from those same components.\nNote that this requires that *Y1* , *Y2* , and *Y3* be left undeleted, so you\nwill be billed for those components as well as for the composite.\n| **Caution:** Compose operations create a new version of an object. When performing appends in a bucket with [Object Versioning](/storage/docs/object-versioning) enabled, be sure that you properly manage the noncurrent version of the object that each append generates.\n\nWhat's next\n-----------\n\n- [Compose an object](/storage/docs/composing-objects).\n- Learn about [parallel composite uploads](/storage/docs/parallel-composite-uploads).\n- Learn about [Multipart uploads](/storage/docs/multipart-uploads), an alternative way to upload objects in multiple chunks for XML API users."]]