Solana Kit

Retrieve a File

Learn how to download and access files from Shelby

Retrieving Files from Shelby

Once you've uploaded files to Shelby, you can retrieve them using several methods.

Using Shelby Explorer

The easiest way to view and download your files is through the Shelby Explorer:

  1. Navigate to the explorer
  2. Search for your storage account address
  3. Browse and download your blobs

Using HTTP GET Request

You can download files directly using a GET request to the Shelby RPC endpoint.

URL Format

https://api.shelbynet.shelby.xyz/shelby/v1/blobs/{account_address}/{blob_name}

cURL Example

curl -X GET "https://api.shelbynet.shelby.xyz/shelby/v1/blobs/0x1234...abcd/example.txt"

Node/React Example

const accountAddress = storageAccount.accountAddress.toString();
const blobName = "example.txt";

const response = await fetch(
  `https://api.shelbynet.shelby.xyz/shelby/v1/blobs/${accountAddress}/${blobName}`
);

if (response.ok) {
  const data = await response.arrayBuffer();
  console.log("Downloaded:", new Uint8Array(data));
} else {
  console.error("Download failed:", response.statusText);
}
const { storageAccountAddress } = useStorageAccount({
  client: shelbyClient,
  solanaAddress: publicKey?.toBase58(),
  signMessageFn: signMessage,
});

const handleDownload = async (blobName: string) => {
  if (!storageAccountAddress) return;

  const response = await fetch(
    `https://api.shelbynet.shelby.xyz/shelby/v1/blobs/${storageAccountAddress}/${blobName}`
  );

  if (response.ok) {
    const blob = await response.blob();
    // Create download link
    const url = URL.createObjectURL(blob);
    const a = document.createElement("a");
    a.href = url;
    a.download = blobName;
    a.click();
    URL.revokeObjectURL(url);
  }
};

Listing Account Blobs

To see all blobs owned by an account, use the Shelby SDK:

import { Shelby, Network } from "@shelby-protocol/solana-kit/node";

const shelbyClient = new Shelby({
  network: Network.SHELBYNET,
  connection,
  apiKey: "AG-***",
});

const blobs = await shelbyClient.getAccountBlobs({
  account: storageAccount.accountAddress.toString(),
});

console.log("Account blobs:");
for (const blob of blobs) {
  console.log(`- ${blob.name} (owner: ${blob.owner})`);
}
import { useAccountBlobs } from "@shelby-protocol/react";
import { useStorageAccount, Network } from "@shelby-protocol/solana-kit/react";
import { ShelbyClient } from "@shelby-protocol/sdk/browser";
import { useEffect, useMemo, useState } from "react";

function BlobList() {
  const { publicKey, signMessage } = useWallet();

  const shelbyClient = useMemo(
    () =>
      new ShelbyClient({
        network: Network.SHELBYNET,
        apiKey: process.env.NEXT_PUBLIC_SHELBY_API_KEY!,
      }),
    []
  );

  const { storageAccountAddress } = useStorageAccount({
    client: shelbyClient,
    solanaAddress: publicKey?.toBase58(),
    signMessageFn: signMessage,
  });

  const { data: blobs } = useAccountBlobs({
    client: shelbyClient,
    account: storageAccountAddress,
  });

  return (
    <ul>
      {blobs.map((blob) => (
        <li key={blob.blobNameSuffix}>
          {blob.blobNameSuffix} -{" "}
          <button onClick={() => handleDownload(blob.blobNameSuffix)}>
            Download
          </button>
        </li>
      ))}
    </ul>
  );
}