> ## Documentation Index
> Fetch the complete documentation index at: https://docs.resq.software/llms.txt
> Use this file to discover all available pages before exploring further.

# ResQ.Storage.IStorageClient.GetAsync(string,System.Threading.CancellationToken)

### [ResQ.Storage](./ResQ.Storage.md "ResQ.Storage").[IStorageClient](./ResQ.Storage.IStorageClient.md "ResQ.Storage.IStorageClient")

## IStorageClient.GetAsync(string, CancellationToken) Method

Retrieves file content by its IPFS CID.

```csharp theme={null}
System.Threading.Tasks.Task<System.IO.Stream> GetAsync(string cid, System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));
```

#### Parameters

<a name="ResQ.Storage.IStorageClient.GetAsync(string,System.Threading.CancellationToken).cid" />

`cid` [System.String](https://learn.microsoft.com/en-us/dotnet/api/system.string "System.String")

The IPFS Content Identifier of the file to retrieve.

<a name="ResQ.Storage.IStorageClient.GetAsync(string,System.Threading.CancellationToken).cancellationToken" />

`cancellationToken` [System.Threading.CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken "System.Threading.CancellationToken")

Cancellation token for the operation.

#### Returns

[System.Threading.Tasks.Task\<](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 "System.Threading.Tasks.Task`1")[System.IO.Stream](https://learn.microsoft.com/en-us/dotnet/api/system.io.stream "System.IO.Stream")[>](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 "System.Threading.Tasks.Task`1")\
A stream containing the file content.

#### Exceptions

[System.ArgumentNullException](https://learn.microsoft.com/en-us/dotnet/api/system.argumentnullexception "System.ArgumentNullException")\
Thrown when cid is null or empty.

[System.InvalidOperationException](https://learn.microsoft.com/en-us/dotnet/api/system.invalidoperationexception "System.InvalidOperationException")\
Thrown when the file cannot be retrieved.

[System.OperationCanceledException](https://learn.microsoft.com/en-us/dotnet/api/system.operationcanceledexception "System.OperationCanceledException")\
Thrown when the operation is cancelled.

### Example

```csharp theme={null}
using var stream = await storage.GetAsync("Qmabc123...");
using var fileStream = File.Create("downloaded.jpg");
await stream.CopyToAsync(fileStream);
```

### Remarks

The content is retrieved through the configured IPFS gateway. The caller is responsible
for disposing the returned stream. In mock mode, returns a mock stream.
