ResQ.Storage.IStorageClient
IStorageClient.UploadAsync Method
| Overloads | |
|---|---|
| UploadAsync(byte[], string, string, Dictionary<string,string>, CancellationToken) | Uploads binary data to IPFS and pins it. |
| UploadAsync(Stream, string, string, Dictionary<string,string>, CancellationToken) | Uploads a file stream to IPFS and pins it. |
IStorageClient.UploadAsync(byte[], string, string, Dictionary<string,string>, CancellationToken) Method
Uploads binary data to IPFS and pins it.Parameters
data System.Byte[]
The file content as a byte array.
fileName System.String
The desired filename for the uploaded content.
contentType System.String
The MIME type of the content.
metadata System.Collections.Generic.Dictionary<System.String,System.String>
Optional dictionary of custom metadata key-value pairs.
cancellationToken System.Threading.CancellationToken
Cancellation token for the operation.
Returns
System.Threading.Tasks.Task<UploadResult>An UploadResult containing the CID and upload metadata.
Exceptions
System.ArgumentNullExceptionThrown when data, fileName, or contentType is null. System.InvalidOperationException
Thrown when the upload fails. System.OperationCanceledException
Thrown when the operation is cancelled.
Example
Remarks
This is a convenience overload that wraps the byte array in a MemoryStream and calls UploadAsync(Stream, string, string, Dictionary<string,string>, CancellationToken).IStorageClient.UploadAsync(Stream, string, string, Dictionary<string,string>, CancellationToken) Method
Uploads a file stream to IPFS and pins it.Parameters
content System.IO.Stream
The file content as a stream. The stream will be read to completion.
fileName System.String
The desired filename for the uploaded content.
contentType System.String
The MIME type of the content (e.g., “image/jpeg”, “application/pdf”).
metadata System.Collections.Generic.Dictionary<System.String,System.String>
Optional dictionary of custom metadata key-value pairs to attach to the pin.
cancellationToken System.Threading.CancellationToken
Cancellation token for the operation.
Returns
System.Threading.Tasks.Task<UploadResult>An UploadResult containing the CID and upload metadata.
Exceptions
System.ArgumentNullExceptionThrown when content, fileName, or contentType is null. System.InvalidOperationException
Thrown when the upload fails. System.OperationCanceledException
Thrown when the operation is cancelled.