Skip to content

Kazarrackt/Kazlabs-File-Share

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KazLabs File Share

A secure, temporary file sharing system with customizable expiry times and download limits.

Features

  • 🚀 Simple, modern web interface for file uploads
  • 🖱️ Drag-and-drop file upload support
  • ⏱️ Customizable file expiry (1 hour to 30 days)
  • 🔢 Maximum download limits
  • 🔗 Short URLs for easy sharing
  • 💻 Curl/API support for command-line uploads
  • 🔐 Admin interface for file management
  • 🗑️ Secure file deletion with delete keys
  • 📊 File statistics and tracking
  • 🛡️ Rate limiting to prevent abuse

Installation

Prerequisites

  • Python 3.8 or higher
  • pip (Python package manager)
  • Git (optional, for cloning the repository)
git clone https://github.com/yourusername/kazlabs-file-share.git
cd kazlabs-file-share

#On Windows
python -m venv venv
venv\Scripts\activate

#On Linux
python3 -m venv venv
source venv/bin/activate

#On MacOS
python3 -m venv venv
source venv/bin/activate

pip install -r requirements.txt

Configuration

This is an example of the config.json file:

{
"UPLOAD_FOLDER": "data",
"META_FOLDER": "meta",
"EXPORT_FOLDER": "Export",
"MAX_CONTENT_LENGTH": 16777216,
"MAX_FILE_SIZE_MB": 16,
"ALLOWED_EXTENSIONS": ["txt", "pdf", "png", "jpg", "jpeg", "gif", "zip", "rar", "7z", "doc", "docx", "xls", "xlsx", "ppt", "pptx"],
"SECRET_KEY": "your-secret-key-here",
"ADMIN_PASSWORD": "change-this-password",
"DEBUG": false,
"MAX_DOWNLOADS": 100,
"WEB_PORT": 5000,
"WEB_HOST": "0.0.0.0",
"WEB_URL": "https://example.com"
}

Usage

Running the application

python app.py

Accessing the Application

Open your browser and navigate to:

http://localhost:8000

Uploading Files

Basic upload

curl -F "file=@/path/to/file" http://localhost:8000/upload/curl

Upload with custom expiry (1h, 24h, 7d, 30d)

curl -F "file=@/path/to/file" -F "expiry=24h" http://localhost:8000/upload/curl

Upload with custom download limit

curl -F "file=@/path/to/file" -F "max_downloads=5" http://localhost:8000/upload/curl

Upload with both expiry and download limit

curl -F "file=@/path/to/file" -F "expiry=7d" -F "max_downloads=100" http://localhost:8000/upload/curl

Admin Interface

Navigate to the admin interface at:

http://localhost:8000/admin

Response Format

The response format is JSON. For example:

{
"success": true,
"urls": {
"full": "http://localhost:8000/f/uniqueid/filename",
"short": "http://localhost:8000/s/shortlink",
"delete": "http://localhost:8000/d/uniqueid/deletekey"
},
"expiry": "24h",
"max_downloads": 10,
"file": {
"name": "example.txt",
"size": 1024,
"content_type": "text/plain"
}
}

API Routes

Method Route Description
GET / Upload page
POST /upload Upload files via web interface
POST /upload/curl Upload files via API
GET /f/<unique_id>/<filename> Download file
GET /s/<short_link> Short link redirect
GET /d/<unique_id>/<delete_key> Delete file with key
GET /admin Admin interface (password protected)
GET /admin/login Admin login page
GET /admin/logout Admin logout
GET /admin/files List all files (admin only)
DELETE /admin/delete/<unique_id>/<filename> Delete file (admin only)

Project Structure

file-share/
├── app.py # Main application entry point
├── config.json # Configuration file
├── logger.py # Custom logging module
├── requirements.txt # Python dependencies
├── README.md # This file
├── changelog.txt # Change history
├── lib/ # Library modules
│ ├── init.py
│ ├── api_handler.py # API response handling
│ ├── auth_manager.py # Authentication management
│ ├── file_handler.py # File operations
│ ├── link_generator.py # URL generation
│ ├── metadata_manager.py # File metadata management
│ └── route_handler.py # Flask route definitions
├── static/ # Static assets
│ ├── script.js # JavaScript for UI
│ └── style.css # CSS styles
└── templates/ # HTML templates
├── admin.html # Admin interface
├── base.html # Base template
├── delete_success.html # Deletion confirmation
├── error.html # Error page
├── login.html # Admin login
├── retrieve.html # File retrieval
├── upload.html # File upload
└── upload_success.html # Upload confirmation

Customization

Changing the Admin Password

Edit the config.json file and update the ADMIN_PASSWORD value.

Changing File Size Limits

Edit the config.json file and update the MAX_CONTENT_LENGTH value (in bytes) and MAX_FILE_SIZE_MB value (for display).

Changing Allowed File Types

Edit the config.json file and update the ALLOWED_EXTENSIONS array.

Customizing the UI

Edit the files in the static/ and templates/ directories to customize the look and feel of the application.

Logging

Logs are stored in the location specified by LOG_LOCATION in your config.json file. The default is logs/file-share.log in the application directory.

The log format is:

[DateTime] [Component] [LogLevel] Message

Security Considerations

  • Change the default admin password in config.json
  • Use HTTPS in production environments
  • Regularly clean up expired files
  • Monitor logs for suspicious activity
  • Consider implementing additional authentication for sensitive deployments

Deployment

Using Gunicorn (Linux/macOS)

  1. Install Gunicorn:
pip install gunicorn
  1. Run with Gunicorn:
gunicorn -w 4 -b 0.0.0.0:8000 app:app

Using Waitress (Windows)

  1. Install Waitress:
python -m pip install waitress
  1. Run with Waitress:
waitress-serve --port=8000 app:app

Troubleshooting

Files Not Uploading

  • Check the file size limit in config.json
  • Ensure the upload directories are writable
  • Check the logs for specific error messages

Admin Access Issues

  • Verify the correct password in config.json
  • Check for session issues (try clearing browser cookies)

API/Curl Upload Problems

  • Ensure the correct curl syntax is being used
  • Check for rate limiting issues
  • Verify the file exists and is readable

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

© 2025 Kazlabs - Made with ♥️ by Liam Sorensen

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published