Thanks for checking out Chrome Music Lab. Unfortunately, your browser doesn’t support the technology that makes these experiments work. For the best experience,view it on Chrome.
Project Title
?

Nurul.zip - Share Files Online (2027)

Complete File Sharing Web App Project Structure nurul-zip-clone/ ├── index.html (Frontend UI) ├── server.js (Node.js backend) ├── package.json (Dependencies) ├── .env (Environment variables) └── uploads/ (Folder for stored files - auto-created)

1. Backend ( server.js ) const express = require('express'); const multer = require('multer'); const path = require('path'); const fs = require('fs'); const crypto = require('crypto'); const cors = require('cors'); require('dotenv').config(); const app = express(); const PORT = process.env.PORT || 3000; // Middleware app.use(cors()); app.use(express.json()); app.use(express.static('public')); // Ensure uploads directory exists const uploadDir = './uploads'; if (!fs.existsSync(uploadDir)) { fs.mkdirSync(uploadDir); } // Configure multer for file uploads const storage = multer.diskStorage({ destination: (req, file, cb) => { cb(null, uploadDir); }, filename: (req, file, cb) => { // Generate unique filename with original extension const uniqueId = crypto.randomBytes(8).toString('hex'); const ext = path.extname(file.originalname); cb(null, ${uniqueId}${ext} ); } }); const upload = multer({ storage: storage, limits: { fileSize: 100 * 1024 * 1024 }, // 100MB limit fileFilter: (req, file, cb) => { // Allow all file types cb(null, true); } }); // Store file metadata const fileMetadata = new Map(); // Routes // Upload file app.post('/upload', upload.single('file'), (req, res) => { try { if (!req.file) { return res.status(400).json({ error: 'No file uploaded' }); } const fileId = path.basename(req.file.filename, path.extname(req.file.filename)); const metadata = { id: fileId, originalName: req.file.originalname, filename: req.file.filename, size: req.file.size, mimetype: req.file.mimetype, uploadDate: new Date(), downloads: 0, expiresAt: req.body.expiresIn ? new Date(Date.now() + (req.body.expiresIn * 24 * 60 * 60 * 1000)) : null };

fileMetadata.set(fileId, metadata);

// Auto-delete expired files (check every hour) setInterval(cleanupExpiredFiles, 3600000); Nurul.zip - Share Files Online

res.json({ success: true, fileId: fileId, downloadUrl: `${req.protocol}://${req.get('host')}/download/${fileId}`, filename: req.file.originalname, size: req.file.size, expiresAt: metadata.expiresAt }); } catch (error) { console.error('Upload error:', error); res.status(500).json({ error: 'Upload failed' }); }

}); // Download file app.get('/download/:fileId', (req, res) => { const fileId = req.params.fileId; const metadata = fileMetadata.get(fileId); if (!metadata) { return res.status(404).json({ error: 'File not found or expired' }); }

// Check if file has expired if (metadata.expiresAt && new Date() > metadata.expiresAt) { fileMetadata.delete(fileId); // Delete physical file fs.unlink(path.join(uploadDir, metadata.filename), (err) => { if (err) console.error('Error deleting expired file:', err); }); return res.status(410).json({ error: 'File has expired' }); } const multer = require(&#39

const filepath = path.join(uploadDir, metadata.filename);

if (!fs.existsSync(filepath)) { return res.status(404).json({ error: 'File not found' }); }

// Increment download counter metadata.downloads++; fileMetadata.set(fileId, metadata); const path = require(&#39

// Send file res.download(filepath, metadata.originalName, (err) => { if (err) { console.error('Download error:', err); } });

}); // Get file info app.get('/info/:fileId', (req, res) => { const fileId = req.params.fileId; const metadata = fileMetadata.get(fileId); if (!metadata) { return res.status(404).json({ error: 'File not found' }); }