Skip to main content

IpfsStorage.upload() method

Upload a file to IPFS and return the hash

Example

const file = "./path/to/file.png"; // Can be a path or a File object such as a file from an input element.
const hash = await sdk.storage.upload(file);

Signature:

upload(data: string | FileOrBuffer, contractAddress?: string, signerAddress?: string, options?: {
onProgress: (event: UploadProgressEvent) => void;
}): Promise<string>;

Parameters

ParameterTypeDescription
datastring | FileOrBuffer
contractAddressstring(Optional)
signerAddressstring(Optional)
options{ onProgress: (event: UploadProgressEvent) => void; }(Optional)

Returns:

Promise<string>

Remarks

This method is a wrapper around IStorage.upload()