<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppIntents",
  "identifier" : "/documentation/AppIntents/IntentFile",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "App Intents"
    ],
    "preciseIdentifier" : "s:10AppIntents10IntentFileV"
  },
  "title" : "IntentFile"
}
-->

# IntentFile

An interface for providing an app entity that represents an on-disk file or file-based resource.

```
struct IntentFile
```

## Overview

Provide an intent file entity implementation to describe data you store in a file on disk or in memory by providing its
associated name and uniform type identifier.

## Topics

### Creating a file

[`init(data: Data, filename: String, type: UTType?)`](/documentation/AppIntents/IntentFile/init(data:filename:type:))

[`init(fileURL: URL, filename: String?, type: UTType?)`](/documentation/AppIntents/IntentFile/init(fileURL:filename:type:))

### Getting the file information

[`var filename: String`](/documentation/AppIntents/IntentFile/filename)

The human-readable name of the file, which will be displayed to the user.

[`var fileURL: URL?`](/documentation/AppIntents/IntentFile/fileURL)

URL to the file on disk, if any.
If the file isn’t stored on disk, access the contents using the `data` property.

[`var type: UTType?`](/documentation/AppIntents/IntentFile/type)

The uniform type identifier of the file. (i.e. “public.json”, “public.png”, or any custom type)
More information about uniform type identifiers can be found in <CoreServices/UTCoreTypes.h>

[`var data: Data`](/documentation/AppIntents/IntentFile/data)

The contents of the file.
If the file was created with a URL, accessing this property will memory map the file contents.

[`var removedOnCompletion: Bool`](/documentation/AppIntents/IntentFile/removedOnCompletion)

Indicates whether the file should be automatically deleted from disk when the Shortcut is
done running. `false` by default.

### Instance Properties

[`var availableContentTypes: [UTType]`](/documentation/AppIntents/IntentFile/availableContentTypes)

Valid content types the `IntentFile` can possibly be converted to.

### Instance Methods

[`func data(contentType: UTType) async throws -> Data`](/documentation/AppIntents/IntentFile/data(contentType:))

Requests an `IntentFile` representation as binary data of the requested content type if possible.

[`func file(contentType: UTType, destinationDirectory: URL?) async throws -> (fileURL: URL, openedInPlace: Bool)`](/documentation/AppIntents/IntentFile/file(contentType:destinationDirectory:))

Requests an `IntentFile` representation as a file url.

[`func withFile<Result>(contentType: UTType, allowOpenInPlace: Bool, fileHandler: (URL, Bool) async throws -> Result) async throws -> Result`](/documentation/AppIntents/IntentFile/withFile(contentType:allowOpenInPlace:fileHandler:))

Requests an `IntentFile` representation as a file url.

### Type Aliases

[`typealias Specification`](/documentation/AppIntents/IntentFile/Specification)

[`typealias UnwrappedType`](/documentation/AppIntents/IntentFile/UnwrappedType)

[`typealias ValueType`](/documentation/AppIntents/IntentFile/ValueType)

### Type Properties

[`static var defaultResolverSpecification: some ResolverSpecification`](/documentation/AppIntents/IntentFile/defaultResolverSpecification)

### Enumerations

[`enum IntentFileError`](/documentation/AppIntents/IntentFile/IntentFileError)

## Relationships

### Conforms To

[`TypeDisplayRepresentable`](/documentation/AppIntents/TypeDisplayRepresentable)

[`IntentValueConvertible`](/documentation/AppIntents/IntentValueConvertible)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Escapable`](/documentation/Swift/Escapable)

[`Hashable`](/documentation/Swift/Hashable)

[`Sendable`](/documentation/Swift/Sendable)

[`InstanceDisplayRepresentable`](/documentation/AppIntents/InstanceDisplayRepresentable)

[`IntentValueExpressing`](/documentation/AppIntents/IntentValueExpressing)

[`Equatable`](/documentation/Swift/Equatable)

[`Encodable`](/documentation/Swift/Encodable)

[`DisplayRepresentable`](/documentation/AppIntents/DisplayRepresentable)

[`Decodable`](/documentation/Swift/Decodable)

[`CustomLocalizedStringResourceConvertible`](/documentation/Foundation/CustomLocalizedStringResourceConvertible)

[`Copyable`](/documentation/Swift/Copyable)

---

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)