# ContentProvider

Roblox Engine API class from Roblox Studio 0.744.0.7441077 (version-7aaa6838d36c4448).

- Inherits from, nearest first: [Instance](https://rapi.sleaze.dev/classes/Instance.md), [Object](https://rapi.sleaze.dev/classes/Object.md)
- Tags: Not creatable, Not replicated, Service
- Memory category: Instances
- HTML page: https://rapi.sleaze.dev/classes/ContentProvider/
- Roblox documentation: https://create.roblox.com/docs/reference/engine/classes/ContentProvider

Service that is used to load content, or assets, into a game.

## Properties

### BaseUrl

```luau
ContentProvider.BaseUrl: string
```

- Tags: Read only, Capabilities: AssetManagement, Save only

Used by the [`ContentProvider`](https://rapi.sleaze.dev/classes/ContentProvider.md) to download assets from the Roblox website.

### RequestQueueSize

```luau
ContentProvider.RequestQueueSize: number
```

- Tags: Read only, Capabilities: AssetManagement, Save only

Gives the number of items in the [`ContentProvider`](https://rapi.sleaze.dev/classes/ContentProvider.md) request queue that need to be downloaded.

## Methods

### GetAssetFetchStatus

```luau
ContentProvider:GetAssetFetchStatus(contentId: string): Enum.AssetFetchStatus
```

- Tags: Capabilities: AssetManagement

Gets the current `AssetFetchStatus` of the `contentId` provided.

Parameters:

- `contentId`: The ID of the content to fetch the status for.

Returns: The `AssetFetchStatus` of the content.

### GetAssetFetchStatusChangedSignal

```luau
ContentProvider:GetAssetFetchStatusChangedSignal(contentId: string): RBXScriptSignal
```

- Tags: Capabilities: AssetManagement

A signal that fires when the `AssetFetchStatus` of the provided content changes.

Parameters:

- `contentId`: The ID of the content to monitor for fetch status changes.

Returns: An [`RBXScriptSignal`](https://rapi.sleaze.dev/index/types/RBXScriptSignal.md) that fires when the `AssetFetchStatus` of the given content changes.

### GetDependencyContentIds

```luau
ContentProvider:GetDependencyContentIds(root: Instance): { any }
```

- Tags: Roblox script security, Capabilities: AssetManagement

### GetDetailedFailedRequests

```luau
ContentProvider:GetDetailedFailedRequests(): { any }
```

- Tags: Roblox script security, Capabilities: AssetManagement

### GetFailedRequests

```luau
ContentProvider:GetFailedRequests(): { any }
```

- Tags: Roblox script security, Capabilities: AssetManagement

### ListEncryptedAssets

```luau
ContentProvider:ListEncryptedAssets(): { any }
```

- Tags: Capabilities: AssetManagement

Returns an array of the asset IDs that currently have a registered encryption key.

Returns: An array of the asset IDs that currently have an encryption key registered on this [`ContentProvider`](https://rapi.sleaze.dev/classes/ContentProvider.md).

### PreloadAsync

```luau
ContentProvider:PreloadAsync(contentIdList: { any }, callbackFunction: ((...any) -> ...any)? = nil)
```

- Tags: Yields, Capabilities: AssetManagement

Yields until all of the assets associated with the given [`Instances`](https://rapi.sleaze.dev/index/types/Instances.md) have loaded.

Parameters:

- `contentIdList`: An array of instances to load.
- `callbackFunction`: The function called when each asset request completes. Returns the `content` string and the asset's final `AssetFetchStatus`.

### RegisterDefaultEncryptionKey

```luau
ContentProvider:RegisterDefaultEncryptionKey(encryptionKey: string)
```

- Tags: Capabilities: AssetManagement

Registers a fallback encryption key used to decrypt any encrypted asset that doesn't have its own key registered.

Parameters:

- `encryptionKey`: The key to use as the default for decrypting encrypted assets.

### RegisterDefaultSessionKey

```luau
ContentProvider:RegisterDefaultSessionKey(sessionKey: string)
```

- Tags: Capabilities: AssetManagement

Decrypts the provided session key and registers the result as the default encryption key.

Parameters:

- `sessionKey`: The session-encrypted key to decrypt and register as the default encryption key.

### RegisterEncryptedAsset

```luau
ContentProvider:RegisterEncryptedAsset(assetId: string, encryptionKey: string)
```

- Tags: Capabilities: AssetManagement

Registers an encryption key used to decrypt a specific encrypted asset.

Parameters:

- `assetId`: The asset to associate the encryption key with.
- `encryptionKey`: The key used to decrypt the specified asset.

### RegisterSessionEncryptedAsset

```luau
ContentProvider:RegisterSessionEncryptedAsset(contentId: string, sessionKey: string)
```

- Tags: Capabilities: AssetManagement

Decrypts the provided session key and registers it as the encryption key for a specific asset.

Parameters:

- `contentId`: The asset to associate the decrypted key with.
- `sessionKey`: The session-encrypted key to decrypt and register for the specified asset.

### SetBaseUrl

```luau
ContentProvider:SetBaseUrl(url: string)
```

- Tags: Local user security, Capabilities: AssetManagement

### UnregisterDefaultEncryptionKey

```luau
ContentProvider:UnregisterDefaultEncryptionKey()
```

- Tags: Capabilities: AssetManagement

Clears the default encryption key previously set on the [`ContentProvider`](https://rapi.sleaze.dev/classes/ContentProvider.md).

### UnregisterEncryptedAsset

```luau
ContentProvider:UnregisterEncryptedAsset(assetId: string)
```

- Tags: Capabilities: AssetManagement

Removes the encryption key registered for a specific asset.

Parameters:

- `assetId`: The asset whose registered encryption key should be removed.

### Preload

```luau
ContentProvider:Preload(contentId: string)
```

- Tags: Deprecated, Capabilities: AssetManagement
- Use instead: [`ContentProvider.PreloadAsync`](https://rapi.sleaze.dev/classes/ContentProvider.md)

**Deprecated:** This item has been superseded by [`ContentProvider:PreloadAsync()`](https://rapi.sleaze.dev/classes/ContentProvider.md) which should be used in all new work.

Queues an asset to be downloaded by the [`ContentProvider`](https://rapi.sleaze.dev/classes/ContentProvider.md).

Parameters:

- `contentId`: The content URL of the asset to preload.

## Events

### AssetFetchFailed

```luau
ContentProvider.AssetFetchFailed: RBXScriptSignal<(assetId: string)>
```

- Tags: Capabilities: AssetManagement

Fires when the [`ContentProvider`](https://rapi.sleaze.dev/classes/ContentProvider.md) fails to fetch an asset, passing the asset's ID.

## Inherited members

- From [Instance](https://rapi.sleaze.dev/classes/Instance.md): `Archivable`, `archivable`, `Attributes`, `AttributesReplicate`, `AttributesSerialize`, `HistoryId`, `Name`, `Parent`, `PredictionMode`, `PropertyStatusStudio`, `RobloxLocked`, `SerializedOverrides`, `SourceAssetId`, `Tags`, `UniqueId`, `numExpectedDirectChildren`, `DataCost`, `Capabilities`, `DefinesCapabilities`, `IsInSandbox`, `Sandboxed`, `AddTag`, `ClearAllChildren`, `Clone`, `Destroy`, `FindFirstAncestor`, `FindFirstAncestorOfClass`, `FindFirstAncestorWhichIsA`, `FindFirstChild`, `FindFirstChildOfClass`, `FindFirstChildWhichIsA`, `FindFirstDescendant`, `GetActor`, `GetAttribute`, `GetAttributeChangedSignal`, `GetAttributes`, `GetChildren`, `GetDebugId`, `GetDescendants`, `GetFullName`, `GetStyled`, `GetStyledPropertyChangedSignal`, `GetTags`, `HasTag`, `IsAncestorOf`, `IsDescendantOf`, `IsPropertyModified`, `QueryDescendants`, `RemoveTag`, `ResetPropertyToDefault`, `SetAttribute`, `WaitForChild`, `Remove`, `children`, `clone`, `destroy`, `findFirstChild`, `getChildren`, `isDescendantOf`, `remove`, `AncestryChanged`, `AttributeChanged`, `ChildAdded`, `ChildRemoved`, `DescendantAdded`, `DescendantRemoving`, `Destroying`, `StyledPropertiesChanged`, `childAdded`
- From [Object](https://rapi.sleaze.dev/classes/Object.md): `ClassName`, `className`, `GetPropertyChangedSignal`, `IsA`, `isA`, `Changed`
