Building Static Websites

Query data from the uncloud storage network

Want to run a static website that queries dynamic data that you own? With uncloud-p2p you can host a light weight site anywhere, and clients pull the data from the nearest avaliable node. Configure a node with the public data, and Uncloud will distribute it across our storage network, for a fraction of the cost.

Say goodbye to egress fees, clients establish a peer to peer connection directly to their nearest avaliable node.

Implementation Guide

From local files to P2P stream in 5 minutes.

01

Ingest Data

Load your datasets into your node by simply dragging and dropping files into the Uncloud Dashboard.

02

Configure Public Access

Create a Public Link to expose your data. You have granular control here: specify exactly which files or directories you want to make accessible to the P2P network.

Creating a public link in Uncloud
03

Integrate the SDK

Copy your linkId. This unique identifier allows the uncloud-p2p NPM package to discover and query your node from any client browser.

04 / Technical Implementation

// Install the package

npm install uncloud-p2p

// Establish P2P Connection

const p2p = new UncloudP2P({
  nodeId: nodeId
});

await p2p.connect();
await p2p.waitForOpen();

// List Remote Files

const files = await ListFiles(p2p);

// Stream to Memory (Buffer/Text)

for (const file of files) {
  if (file.Name.endsWith(".csv")) {
    const blob = await p2p.downloadToMemory(file.Name);
    stockDataCache.set(file.Name, await blob.text());
  }
}

// Direct Download to User Device

p2p.downloadFile(files.Name)
05

Live Result

Working example of Stock Explorer app

Fig 1.0: Real-time P2P Visualization App