<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Free Cloud Storage (100TB) - Upload, Categorize, Download</title>
<style>
* {
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
margin: 0; padding:0;
background: #f0f2f5;
color: #333;
}
header {
background: #0078d7;
color: white;
padding: 1rem 2rem;
text-align: center;
}
main {
max-width: 960px;
margin: 2rem auto;
background: white;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
padding: 1rem 2rem 3rem;
border-radius: 6px;
}
h1 {
margin: 0;
}
.upload-section {
border: 2px dashed #0078d7;
border-radius: 8px;
padding: 1rem;
text-align: center;
cursor: pointer;
color: #0078d7;
margin-bottom: 1rem;
user-select: none;
position: relative;
}
.upload-section.hover {
background: #e6f0ff;
}
input[type=file] {
display: none;
}
#categories-input {
margin-top: 0.5rem;
padding: 0.4rem 0.7rem;
font-size: 1rem;
border-radius: 4px;
border: 1px solid #ccc;
width: 100%;
}
#add-category-btn {
margin-top: 0.5rem;
padding: 0.4rem 0.7rem;
font-size: 1rem;
border: none;
border-radius: 4px;
background: #0078d7;
color: white;
cursor: pointer;
user-select: none;
}
#add-category-btn:disabled {
background: #999;
cursor: default;
}
#categories-list {
margin-top: 1rem;
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
}
.category-pill {
background: #0078d7;
color: white;
padding: 0.3rem 0.8rem;
border-radius: 20px;
font-size: 0.9rem;
user-select: none;
cursor: pointer;
position: relative;
}
.category-pill.selected {
background: #004a8f;
}
.category-remove {
margin-left: 0.5rem;
font-weight: bold;
cursor: pointer;
user-select: none;
}
.files-section {
margin-top: 2rem;
}
.files-header {
display: flex;
justify-content: space-between;
align-items: center;
}
#storage-info {
font-weight: 600;
font-size: 1rem;
}
#clear-all-btn {
background: #d9534f;
color: white;
padding: 0.4rem 0.8rem;
border: none;
border-radius: 4px;
cursor: pointer;
user-select: none;
}
#clear-all-btn:hover {
background: #c9302c;
}
#file-list {
margin-top: 1rem;
list-style: none;
padding: 0;
max-height: 500px;
overflow-y: auto;
border-top: 1px solid #ddd;
}
#file-list li {
display: flex;
align-items: center;
padding: 0.5rem 0;
border-bottom: 1px solid #eee;
gap: 1rem;
}
#file-list li label {
flex-grow: 1;
cursor: pointer;
user-select: none;
}
#file-list li .file-info {
font-size: 0.85rem;
color: #666;
}
.file-category {
background: #eee;
border-radius: 4px;
padding: 0.1rem 0.4rem;
margin-left: 0.3rem;
font-size: 0.75rem;
color: #444;
}
.category-filter {
margin-top: 1rem;
}
.category-filter > label {
user-select: none;
margin-right: 1rem;
cursor: pointer;
}
.btn {
border: none;
border-radius: 4px;
padding: 0.5rem 1rem;
cursor: pointer;
user-select: none;
}
.btn-primary {
background: #0078d7;
color: white;
}
.btn-primary:disabled {
background: #999;
cursor: default;
}
.btn-danger {
background: #d9534f;
color: white;
}
.btn-sm {
padding: 0.3rem 0.6rem;
font-size: 0.85rem;
}
.loading-screen {
position: fixed;
top: 0; left: 0;
width: 100vw;
height: 100vh;
background: rgba(255,255,255,0.8);
display: flex;
justify-content: center;
align-items: center;
font-size: 1.5rem;
color: #0078d7;
z-index: 9999;
user-select: none;
}
.loading-screen .spinner {
border: 5px solid #ccc;
border-top: 5px solid #0078d7;
border-radius: 50%;
width: 50px;
height: 50px;
margin-right: 1rem;
animation: spin 1s linear infinite;
}
@keyframes spin {
to { transform: rotate(360deg);}
}
#download-zip-btn {
margin-left: 1rem;
}
.no-files-msg {
color: #777;
margin-top: 1rem;
font-style: italic;
text-align: center;
}
footer {
text-align: center;
margin-top: 3rem;
font-size: 0.9rem;
color: #666;
}
a {
color: #0078d7;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<header>
<h1>Free Cloud Storage (100TB) - Unlimited Categories & 100GB max/file</h1>
</header>
<main>
<section class="upload-section" id="upload-dropzone" tabindex="0" aria-label="File upload area">
Click or drag & drop files here to upload (max 100GB per file)
<input type="file" id="file-input" multiple />
<div style="margin-top:0.7rem; font-size:0.9rem; color:#555;">
Select category for uploaded files:
</div>
<div id="categories-list" aria-label="Select categories to assign to uploaded files" role="listbox" tabindex="0"></div>
</section>
<div style="margin-top:0.5rem;">
<input type="text" id="categories-input" placeholder="New category name (enter or click Add)" aria-label="New category name" />
<button id="add-category-btn" disabled>Add Category</button>
</div>
<section class="category-filter" aria-label="Filter files by category">
<strong>Filter files by categories:</strong>
<span id="filter-categories-container" style="margin-left:0.5rem;"></span>
<button id="filter-clear-btn" class="btn btn-sm" style="margin-left:0.5rem; display:none;">Clear Filter</button>
</section>
<section class="files-section" aria-live="polite" aria-relevant="additions removals">
<div class="files-header">
<div id="storage-info" aria-live="polite" aria-atomic="true"></div>
<div>
<button id="download-zip-btn" class="btn btn-primary btn-sm" disabled title="Download all selected files as ZIP">Download ZIP</button>
<button id="clear-all-btn" class="btn btn-danger btn-sm" title="Remove all files and categories">Clear All</button>
</div>
</div>
<ul id="file-list" aria-label="Uploaded files list" tabindex="0"></ul>
<div class="no-files-msg" id="no-files-msg" hidden>No files uploaded yet.</div>
</section>
</main>
<div class="loading-screen" id="loading-screen" role="alert" aria-live="assertive" aria-busy="true" hidden>
<div class="spinner"></div>
Uploading files... Please wait 5 seconds.
</div>
<footer>
Free, no sign-up required. Designed & powered by local browser storage.<br />
<a href="https://github.com/" target="_blank" rel="noopener">Source Code</a> available on GitHub.
</footer>
<script src="https://cdn.jsdelivr.net/npm/jszip@3.10.1/dist/jszip.min.js"></script>
<script>
(() => {
const MAX_STORAGE_BYTES = 100 * 1024 ** 4; // 100 TB = 100 * 1024^4 bytes
const MAX_FILE_BYTES = 100 * 1024 ** 3; // 100 GB
const UPLOAD_TIME_MS = 5000; // 5 seconds upload simulation
// All data is stored in localStorage under keys:
// cloud_files = JSON.stringify({ id: {name, size, dataBase64, categories:[] }})
// cloud_categories = JSON.stringify([categoryName1, categoryName2, ...])
// To reduce serialization overhead: large files are stored as base64 strings in localStorage.
// This is heavy in size but acceptable for demonstration.
// In real cloud storage service, files would be on server or indexedDB, here localStorage max 5-10MB per origin exists but ignoring that limit for demo purpose.
// In reality, cannot store 100TB in localStorage; but this is a demo assuming no size limits in browser localStorage.
// Utility: convert bytes to human-readable string:
function formatBytes(bytes){
if (bytes >= 1e12) return (bytes/1e12).toFixed(2) + " TB";
else if (bytes >= 1e9 ) return (bytes/1e9).toFixed(2) + " GB";
else if (bytes >= 1e6 ) return (bytes/1e6).toFixed(2) + " MB";
else if (bytes >= 1e3 ) return (bytes/1e3).toFixed(2) + " KB";
else return bytes + " B";
}
// Generate unique incremental ID:
function generateId(){
let id = parseInt(localStorage.getItem('cloud_id_counter')||'0',10)+1;
localStorage.setItem('cloud_id_counter', id);
return id.toString();
}
// Load files:
function loadFiles(){
try {
return JSON.parse(localStorage.getItem('cloud_files') || '{}');
} catch {
return {};
}
}
// Save files:
function saveFiles(files){
localStorage.setItem('cloud_files', JSON.stringify(files));
}
// Load categories:
function loadCategories(){
try {
return JSON.parse(localStorage.getItem('cloud_categories') || '[]');
} catch {
return [];
}
}
// Save categories:
function saveCategories(categories){
localStorage.setItem('cloud_categories', JSON.stringify(categories));
}
// Encode ArrayBuffer to Base64:
function arrayBufferToBase64(buffer) {
let binary = '';
let bytes = new Uint8Array(buffer);
let len = bytes.byteLength;
for(let i=0; i<len; i++) {
binary += String.fromCharCode(bytes[i]);
}
return btoa(binary);
}
// Decode Base64 to Uint8Array
function base64ToUint8Array(base64) {
let binary_string = atob(base64);
let len = binary_string.length;
let bytes = new Uint8Array(len);
for(let i=0; i < len; i++) {
bytes[i] = binary_string.charCodeAt(i);
}
return bytes;
}
// DOM refs
const uploadDropzone = document.getElementById('upload-dropzone');
const fileInput = document.getElementById('file-input');
const categoriesInput = document.getElementById('categories-input');
const addCategoryBtn = document.getElementById('add-category-btn');
const categoriesList = document.getElementById('categories-list');
const filterCategoriesContainer = document.getElementById('filter-categories-container');
const filterClearBtn = document.getElementById('filter-clear-btn');
const fileListEl = document.getElementById('file-list');
const noFilesMsg = document.getElementById('no-files-msg');
const storageInfo = document.getElementById('storage-info');
const clearAllBtn = document.getElementById('clear-all-btn');
const downloadZipBtn = document.getElementById('download-zip-btn');
const loadingScreen = document.getElementById('loading-screen');
// State
let files = loadFiles();
let categories = loadCategories();
let selectedCategoriesForUpload = new Set();
let filterCategories = new Set();
let selectedFilesForZip = new Set();
// === UI Update functions ===
function updateAddCategoryButtonState(){
const val = categoriesInput.value.trim();
addCategoryBtn.disabled = !val || categories.includes(val);
}
function renderCategoriesList(){
categoriesList.innerHTML = '';
if (categories.length === 0) {
categoriesList.innerHTML = '<small style="color:#777;">No categories yet. Add a new category below.</small>';
return;
}
categories.forEach(cat => {
const catEl = document.createElement('div');
catEl.className = 'category-pill';
catEl.textContent = cat;
if(selectedCategoriesForUpload.has(cat)){
catEl.classList.add('selected');
}
catEl.tabIndex = 0;
catEl.setAttribute('role', 'option');
catEl.setAttribute('aria-selected', selectedCategoriesForUpload.has(cat) ? 'true' : 'false');
// Click to toggle selection:
catEl.addEventListener('click', () => {
if(selectedCategoriesForUpload.has(cat)){
selectedCategoriesForUpload.delete(cat);
catEl.classList.remove('selected');
catEl.setAttribute('aria-selected', 'false');
} else {
selectedCategoriesForUpload.add(cat);
catEl.classList.add('selected');
catEl.setAttribute('aria-selected', 'true');
}
});
catEl.addEventListener('keydown', e => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
catEl.click();
} else if (e.key === 'Delete' || e.key === 'Backspace'){
e.preventDefault();
removeCategory(cat);
}
});
// Add remove X:
const removeX = document.createElement('span');
removeX.textContent = '×';
removeX.className = 'category-remove';
removeX.title = `Delete category "${cat}" (removes from all files)`;
removeX.addEventListener('click', e => {
e.stopPropagation();
removeCategory(cat);
});
catEl.appendChild(removeX);
categoriesList.appendChild(catEl);
});
}
function renderFilterCategories(){
filterCategoriesContainer.innerHTML = '';
if(categories.length === 0) return;
categories.forEach(cat => {
const label = document.createElement('label');
label.style.userSelect = 'none';
const checkbox = document.createElement('input');
checkbox.type = 'checkbox';
checkbox.value = cat;
checkbox.checked = filterCategories.has(cat);
checkbox.addEventListener('change', () => {
if(checkbox.checked){
filterCategories.add(cat);
} else {
filterCategories.delete(cat);
}
if(filterCategories.size === 0) {
filterClearBtn.style.display = 'none';
} else {
filterClearBtn.style.display = '';
}
renderFileList();
updateSelectedFilesForZipState();
});
label.appendChild(checkbox);
label.appendChild(document.createTextNode(' ' + cat));
filterCategoriesContainer.appendChild(label);
});
}
function renderFileList(){
fileListEl.innerHTML = '';
// Gather files filtered by categories if any filter applied:
let filesArr = Object.entries(files);
if (filterCategories.size) {
filesArr = filesArr.filter(([,f]) => {
// file categories intersect filterCategories?
return f.categories.some(cat => filterCategories.has(cat));
});
}
if(filesArr.length === 0){
noFilesMsg.hidden = false;
downloadZipBtn.disabled = true;
return;
} else {
noFilesMsg.hidden = true;
}
filesArr.forEach(([id, file]) => {
// li with checkbox, name, size, categories, download button, remove button
const li = document.createElement('li');
li.tabIndex = 0;
// checkbox:
const checkbox = document.createElement('input');
checkbox.type = 'checkbox';
checkbox.value = id;
checkbox.setAttribute('aria-label', `Select file ${file.name} for ZIP download`);
checkbox.checked = selectedFilesForZip.has(id);
checkbox.addEventListener('change', () => {
if(checkbox.checked){
selectedFilesForZip.add(id);
} else {
selectedFilesForZip.delete(id);
}
updateSelectedFilesForZipState();
});
li.appendChild(checkbox);
// label with file name and categories:
const label = document.createElement('label');
label.textContent = file.name + ' ';
label.className = 'file-info';
// categories labels:
file.categories.forEach(cat => {
const catSpan = document.createElement('span');
catSpan.className = 'file-category';
catSpan.textContent = cat;
label.appendChild(catSpan);
});
li.appendChild(label);
// size span:
const sizeSpan = document.createElement('span');
sizeSpan.textContent = formatBytes(file.size);
sizeSpan.style.marginRight = '1rem';
sizeSpan.style.color = '#666';
sizeSpan.style.fontSize = '0.85rem';
li.appendChild(sizeSpan);
// Download individual button:
const downloadBtn = document.createElement('button');
downloadBtn.textContent = 'Download';
downloadBtn.className = "btn btn-primary btn-sm";
downloadBtn.title = `Download file ${file.name}`;
downloadBtn.addEventListener('click', () => {
downloadFile(file);
});
li.appendChild(downloadBtn);
// Remove file button:
const removeBtn = document.createElement('button');
removeBtn.textContent = 'Remove';
removeBtn.className = "btn btn-danger btn-sm";
removeBtn.title = `Remove file ${file.name}`;
removeBtn.addEventListener('click', () => {
removeFile(id);
});
li.appendChild(removeBtn);
fileListEl.appendChild(li);
});
updateSelectedFilesForZipState();
}
function updateStorageInfo(){
// Sum size of all files:
let totalBytes = 0;
Object.values(files).forEach(f => totalBytes += f.size);
storageInfo.textContent = `Used storage: ${formatBytes(totalBytes)} / 100 TB`;
}
function updateSelectedFilesForZipState(){
downloadZipBtn.disabled = selectedFilesForZip.size === 0;
}
// === Actions ===
async function uploadFiles(fileList){
if(fileList.length === 0) return;
// Filter files by size <= 100GB:
const validFiles = [];
for(let f of fileList){
if(f.size > MAX_FILE_BYTES){
alert(`File "${f.name}" exceeds the maximum allowed size of 100GB and will be skipped.`);
} else {
validFiles.push(f);
}
}
if(validFiles.length === 0) return;
// Check if enough free space:
let usedBytes = 0;
Object.values(files).forEach(f => usedBytes += f.size);
let uploadingBytes = validFiles.reduce((a,f) => a + f.size, 0);
if(usedBytes + uploadingBytes > MAX_STORAGE_BYTES){
alert('Not enough free storage for all selected files. Upload aborted.');
return;
}
// Show loading
loadingScreen.hidden = false;
// Simulate 5 seconds upload time
await new Promise(r => setTimeout(r, UPLOAD_TIME_MS));
for(let file of validFiles){
const arrayBuffer = await file.arrayBuffer();
const base64Data = arrayBufferToBase64(arrayBuffer);
let id = generateId();
files[id] = {
name: file.name,
size: file.size,
dataBase64: base64Data,
categories: Array.from(selectedCategoriesForUpload),
};
}
saveFiles(files);
loadingScreen.hidden = true;
alert('Upload complete!');
renderFileList();
updateStorageInfo();
// Clear fileInput files (important for next upload same files):
fileInput.value = '';
}
function downloadFile(file){
try {
const uint8Arr = base64ToUint8Array(file.dataBase64);
const blob = new Blob([uint8Arr]);
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = file.name;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
} catch(e) {
alert('Error downloading file.');
console.error(e);
}
}
async function downloadZip(){
if(selectedFilesForZip.size === 0) return;
loadingScreen.hidden = false;
try {
const zip = new JSZip();
for(let id of selectedFilesForZip){
if(!files[id]) continue;
const file = files[id];
const uint8Arr = base64ToUint8Array(file.dataBase64);
zip.file(file.name, uint8Arr);
}
const content = await zip.generateAsync({type:"blob"});
const url = URL.createObjectURL(content);
const a = document.createElement('a');
a.href = url;
a.download = `cloud_files_${new Date().toISOString().slice(0,10)}.zip`;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
} catch(e){
alert('Error creating zip for download.');
console.error(e);
} finally {
loadingScreen.hidden = true;
}
}
function removeFile(id){
if(!files[id]) return;
if(!confirm(`Are you sure you want to remove the file "${files[id].name}"?`))
return;
delete files[id];
selectedFilesForZip.delete(id);
saveFiles(files);
renderFileList();
updateStorageInfo();
}
function removeCategory(cat){
if(!categories.includes(cat)) return;
if(!confirm(`Removing category "${cat}" will remove it from all files. Continue?`))
return;
// Remove category from categories list
categories = categories.filter(c => c !== cat);
// Remove from files categories
for(let f of Object.values(files)){
f.categories = f.categories.filter(c => c !== cat);
}
// Also from selected categories for upload and filters:
selectedCategoriesForUpload.delete(cat);
filterCategories.delete(cat);
saveCategories(categories);
saveFiles(files);
renderCategoriesList();
renderFilterCategories();
renderFileList();
}
function clearAllData(){
if(!confirm('Are you sure you want to clear ALL files and categories? This action can not be undone.'))
return;
files = {};
categories = [];
selectedCategoriesForUpload.clear();
filterCategories.clear();
selectedFilesForZip.clear();
localStorage.removeItem('cloud_files');
localStorage.removeItem('cloud_categories');
localStorage.removeItem('cloud_id_counter');
renderCategoriesList();
renderFileList();
renderFilterCategories();
updateStorageInfo();
updateSelectedFilesForZipState();
}
// === Setup events ===
// Drag & drop upload:
uploadDropzone.addEventListener('click', e => {
fileInput.click();
});
uploadDropzone.addEventListener('dragover', e => {
e.preventDefault();
uploadDropzone.classList.add('hover');
});
uploadDropzone.addEventListener('dragleave', e => {
uploadDropzone.classList.remove('hover');
});
uploadDropzone.addEventListener('drop', e => {
e.preventDefault();
uploadDropzone.classList.remove('hover');
uploadFiles(e.dataTransfer.files);
});
// File input change
fileInput.addEventListener('change', () => {
uploadFiles(fileInput.files);
});
// Add category input:
categoriesInput.addEventListener('input', updateAddCategoryButtonState);
addCategoryBtn.addEventListener('click', () => {
let val = categoriesInput.value.trim();
if(!val) return;
if(categories.includes(val)){
alert('Category already exists');
categoriesInput.value = '';
updateAddCategoryButtonState();
return;
}
categories.push(val);
saveCategories(categories);
categoriesInput.value = '';
updateAddCategoryButtonState();
renderCategoriesList();
renderFilterCategories();
});
filterClearBtn.addEventListener('click', () => {
filterCategories.clear();
renderFilterCategories();
renderFileList();
filterClearBtn.style.display = 'none';
});
// Clear all data btn
clearAllBtn.addEventListener('click', clearAllData);
// Download ZIP btn
downloadZipBtn.addEventListener('click', downloadZip);
// Accessibility: support keyboard toggling of categories in upload selection
categoriesList.addEventListener('keydown', e => {
if(e.target.classList.contains('category-pill')){
if (e.key === 'Enter' || e.key === ' '){
e.preventDefault();
e.target.click();
}
}
});
// Initialize UI
renderCategoriesList();
renderFilterCategories();
renderFileList();
updateStorageInfo();
})();
</script>
</body>
</html>