Transferring or sharing very large files (like 30GB) purely via client-side HTML/CSS/JS running in a browser is extremely challenging due to browser sandbox limitations, lack of direct peer-to-peer support, and file size constraints.
However, depending on what exactly you want (e.g., sharing the file from one user to another, or making it downloadable via a web page), there are some approaches:
1. Using a server + simple web UI to upload and share the file
How it works:
- User A uploads the big file (30GB) to your server.
- Server stores the file.
- Server generates a shareable URL (could be
https://server/#/unique-file-id).
- User B opens that URL and downloads the file.
This method requires:
- Server capable of handling large file uploads (chunked uploads recommended).
- Storage large enough to hold the file.
- Web UI (HTML/JS/CSS) to upload/download.
2. Pure client-side approach: WebTorrent or WebRTC based peer-to-peer file sharing
This is complex but possible. The core idea:
- You create a torrent/magnet link for the file in-browser.
- Use WebTorrent (JS library) for browser-based P2P sharing.
- Other users can download directly from your browser (file must remain open to seed).
- Uses peer-to-peer, no server storage.
Limitations:
- You need both parties online at the same time.
- Browser memory/storage limitations may make large files difficult.
- Requires your own signaling/tracker or public WebRTC tracker.
3. Use existing services for large file sharing
Try using cloud storage services designed for large file sharing, then embed/download links within your page.
Sample Client-Side Concept Using WebTorrent for Large File Sharing
Below is a conceptual example that seeds a file locally and generates a magnet link you can share. The receiver uses the magnet link to download.
Limitations:
- File remains in your browser tab during seeding.
- Browser must support large file blobs.
- 30GB is very large; may not be feasible in all browsers.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>File Share with WebTorrent</title>
<style>
body { font-family: Arial, sans-serif; padding: 20px; }
textarea { width: 100%; height: 80px; }
</style>
</head>
<body>
<h2>Send a File (Seed)</h2>
<input type="file" id="fileInput" />
<button id="seedBtn">Seed</button>
<p id="magnetLink"></p>
<hr />
<h2>Receive a File (Download)</h2>
<textarea id="magnetInput" placeholder="Paste magnet link here..."></textarea>
<button id="downloadBtn">Download</button>
<progress id="downloadProgress" max="100" value="0" style="width:100%"></progress>
<p id="status"></p>
<script src="https://cdn.jsdelivr.net/npm/webtorrent/webtorrent.min.js"></script>
<script>
const client = new WebTorrent();
// Seed file
document.getElementById('seedBtn').onclick = () => {
const fileInput = document.getElementById('fileInput');
if (!fileInput.files.length) {
alert('Select a file to seed first!');
return;
}
const file = fileInput.files[0];
client.seed(file, torrent => {
const magnet = torrent.magnetURI;
document.getElementById('magnetLink').innerText = 'Magnet link:\n' + magnet;
alert('Seeding started. Share the magnet link.');
});
};
// Download file using magnet link
document.getElementById('downloadBtn').onclick = () => {
const magnet = document.getElementById('magnetInput').value.trim();
if(!magnet) {
alert('Paste a magnet link!');
return;
}
document.getElementById('status').innerText = 'Starting download...';
client.add(magnet, torrent => {
torrent.files.forEach(file => {
file.getBlobURL((err, url) => {
if (err) {
document.getElementById('status').innerText = 'Error getting blob URL';
return;
}
const a = document.createElement('a');
a.href = url;
a.download = file.name;
a.textContent = 'Click here to download ' + file.name;
document.getElementById('status').innerHTML = '';
document.getElementById('status').appendChild(a);
});
});
torrent.on('download', bytes => {
const progress = (torrent.downloaded / torrent.length * 100).toFixed(2);
document.getElementById('downloadProgress').value = progress;
document.getElementById('status').innerText = `Downloading... ${progress}%`;
});
torrent.on('done', () => {
document.getElementById('status').innerText = 'Download complete!';
document.getElementById('downloadProgress').value = 100;
});
});
};
</script>
</body>
</html>
Explanation
- The seeder user selects a file and clicks Seed. WebTorrent seeds it from the browser.
- The magnet link obtained is shared.
- Another user pastes the magnet link into the receiver's textarea and clicks Download.
- File downloads via WebRTC P2P. When complete, a link appears to download the file.
Important
- This is experimental for huge files. Ideally used for smaller files or in controlled environments.
- For production or very large files, a dedicated server or cloud solution is best.
- WebTorrent’s browser version uses WebRTC under the hood.
If you want me to help with a server-side code sample (Node.js + Express + chunked upload) or cloud integration for this, please ask!