<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: -",
    "macOS: 15.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 2.0.0 -",
    "watchOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppIntents",
  "identifier" : "/documentation/AppIntents/IntentFile/file(contentType:destinationDirectory:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "App Intents",
      "AppIntents"
    ],
    "preciseIdentifier" : "s:10AppIntents10IntentFileV4file11contentType20destinationDirectory10Foundation3URLV0eK0_Sb13openedInPlacet07UniformG11Identifiers6UTTypeV_AISgtYaKF"
  },
  "title" : "file(contentType:destinationDirectory:)"
}
-->

# file(contentType:destinationDirectory:)

Requests an `IntentFile` representation as a file url.

```
func file(contentType: UTType, destinationDirectory: URL? = nil) async throws -> (fileURL: URL, openedInPlace: Bool)
```

## Parameters

`contentType`

A content type of the returned data.

`destinationDirectory`

The directory the file should be copied to,
if no directory is provided the file is opened in place.

## Discussion

If a destination directory is not given the file is opened in place, falling back to a temporary directory if this fails.
If the file is not opened in place and a destination directory is used
it is the caller’s responsibility to remove the file.

---

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)