<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.10.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -",
    "watchOS: 3.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CloudKit",
  "identifier" : "/documentation/CloudKit/CKAsset",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "CloudKit"
    ],
    "preciseIdentifier" : "c:objc(cs)CKAsset"
  },
  "title" : "CKAsset"
}
-->

# CKAsset

An external file that belongs to a record.

```
class CKAsset
```

## Overview

Use assets to incorporate external files into your app’s records, such as photos, videos, and binary files. Alternatively, use assets when a field’s value is more than a few kilobytes in size. To associate an instance of [`CKAsset`](/documentation/CloudKit/CKAsset) with a record, assign it to one of its fields.

> Note: CloudKit stores only an asset’s data. If you require its filename, or any other file-system metadata, use one or more separate fields on the record to store it.

CloudKit stores an asset’s data separately from a record that references it, but maintains an association with that record. When you save a record that has an asset, CloudKit saves both the record and the asset to the server. Similarly, when you fetch the record, the server returns the record and the asset.

When you fetch a record that contains an asset, CloudKit stores the asset’s data in a staging area accessible to your app. Use the asset’s [`fileURL`](/documentation/CloudKit/CKAsset/fileURL) property to access its staged location. The system regularly deletes files in the staging area to reclaim disk space. To avoid this behavior, move the data into your app’s container as soon as you fetch it.

If you don’t require the asset when retrieving records, use the operation’s `desiredKeys` property to exclude the field. For more information, see [`CKFetchRecordsOperation`](/documentation/CloudKit/CKFetchRecordsOperation), [`CKQueryOperation`](/documentation/CloudKit/CKQueryOperation), and [`CKFetchRecordZoneChangesOperation`](/documentation/CloudKit/CKFetchRecordZoneChangesOperation).

If you no longer require an asset that’s on the server, you don’t delete it. Instead, orphan the asset by setting any fields that contain the asset to `nil` and then saving the record. CloudKit periodically deletes orphaned assets from the server.

## Topics

### Creating an Asset

[`init(fileURL:)`](/documentation/CloudKit/CKAsset/init(fileURL:))

Creates an asset that references a file.

### Getting the URL of the Asset

[`fileURL`](/documentation/CloudKit/CKAsset/fileURL)

The URL for accessing the asset.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)