@blockroll/cdn
v1.0.1
Published
BlockRoll CDN Bundle - Vanilla JavaScript SDK for any website
Downloads
13
Maintainers
Readme
@blockroll/cdn
BlockRoll CDN Bundle - Vanilla JavaScript SDK for any website
📦 Installation
Just add the script tag to your HTML:
<script src="https://cdn.jsdelivr.net/npm/@blockroll/cdn@latest/dist/blockroll.min.js"></script>⚡ Quick Start
<!DOCTYPE html>
<html>
<head>
<title>BlockRoll Demo</title>
<script src="https://cdn.jsdelivr.net/npm/@blockroll/cdn@latest/dist/blockroll.min.js"></script>
</head>
<body>
<input type="file" id="fileInput" />
<button onclick="upload()">Upload</button>
<p id="status"></p>
<script>
// Initialize BlockRoll
const blockroll = new BlockRoll({
apiKey: 'YOUR_API_KEY',
realtime: true, // Enable WebSocket
});
// Upload file
async function upload() {
const fileInput = document.getElementById('fileInput');
const file = fileInput.files[0];
if (!file) {
alert('Please select a file');
return;
}
try {
document.getElementById('status').textContent = 'Uploading...';
const result = await blockroll.files.upload({
file,
accessType: 'private',
encryption: true,
});
document.getElementById('status').textContent =
`Uploaded! File ID: ${result.fileId}`;
} catch (error) {
document.getElementById('status').textContent =
`Error: ${error.message}`;
}
}
</script>
</body>
</html>🎯 API Reference
Files
blockroll.files.upload(options)
blockroll.files.list(options)
blockroll.files.download(fileId)
blockroll.files.share(options)
blockroll.files.revoke(fileId, wallet)
blockroll.files.delete(fileId)Workspace
blockroll.workspace.create(options)
blockroll.workspace.addMember(options)
blockroll.workspace.list()Notifications
blockroll.notifications.list(options)
blockroll.notifications.subscribe(callback)
blockroll.notifications.markAsRead(id)🎯 Features
- ✅ No build step required
- ✅ Works in any HTML page
- ✅ Real-time WebSocket support
- ✅ Complete file management API
- ✅ Workspace collaboration
- ✅ Cross-browser compatible
📚 Full Documentation
See parent README for complete examples.
📄 License
MIT License
