Storage
Get the instance of the ThirdwebStorage
class being used by the ThirdwebProvider
.
Allows you to use the TypeScript SDK functionality of Storage in your React native app.
useStorage hook
Configurable in the storageInterface
prop of the ThirdwebProvider
.
The hook returns a ThirdwebStorage
instance.
import { useStorage } from "@thirdweb/react-native";
Usage
import { useStorage } from "@thirdweb-dev/react-native";
export default function Component() {
const storage = useStorage();
...
// Now you can use the functionality of the ThirdwebStorage class:
const resp = await storage?.download("ipfs-url"); // Download a file from IPFS
if (resp.ok) {
const value = await resp?.json();
}
const fileIpfsHash = await storage?.upload({
name: 'file1',
type: 'file-mime-type',
uri: 'file-uri-on-device',
}); // Upload a file to IPFS
const objIpfsHash = await storage?.upload({key: 'value'}); // Upload an object to IPFS
const strIpfsHash = await storage?.upload('string-to-upload'); // Upload a string to IPFS
}