---
title: "read(length:from:completionHandler:)"
framework: MediaExtension
role: symbol
role_heading: Instance Method
platforms: [macOS 14.0+]
path: "mediaextension/mebytesource/read(length:from:completionhandler:)"
---

# read(length:from:completionHandler:)

Reads bytes from a byte source into a data object.

## Declaration

```swift
func read(length: Int, from offset: Int64, completionHandler: @escaping @Sendable (Data?, (any Error)?) -> Void)
```

```swift
func read(length: Int, from offset: Int64) async throws -> Data
```

## Parameters

- `length`: The number of bytes to read.
- `offset`: The relative offset in bytes from the beginning of the file from which to start reading.
- `completionHandler`: The completion block to execute when the read operation finishes.

## See Also

### Performing operations on a byte source

- [availableLength(at:)](mediaextension/mebytesource/availablelength(at:).md)
- [byteSourceForRelatedFileName(_:)](mediaextension/mebytesource/bytesourceforrelatedfilename(_:).md)
