FileShare - Secure File Uploader
FileShare is a simple web application for securely uploading and sharing files using the Telegram Bot API. It allows users to upload files up to 50MB, retrieve download URLs, and copy URLs easily.
const fetch = require('node-fetch');
const FormData = require('form-data');
const { fromBuffer } = require('file-type');
const cheerio = require('cheerio');
/**
* Upload image to url
* Supported mimetype:
* - `image/jpeg`
* - `image/jpg`
* - `image/png`
* - `video/mp4`
* - `all files`
* @param {Buffer} buffer Image Buffer
*/
module.exports = async (buffer) => {
let { ext } = await fromBuffer(buffer);
const bodyForm = new FormData();
bodyForm.append("file", buffer, "file." + ext);
const response = await fetch("https://uptele.onrender.com/api/upload", {
method: "POST",
body: bodyForm,
});
const html = await response.text();
const $ = cheerio.load(html);
const resultUrl = $('input.highlight-url').first().val();
return resultUrl
}- File Upload: Supports all file types up to 50MB.
- Download URLs: Each uploaded file gets a unique download URL.
- Responsive Design: User-friendly interface for both desktop and mobile devices.
- Security: Telegram token stored in
.envto prevent leaks.
- Node.js (version 18 or higher)
- npm
- Telegram account with a Bot Token and Chat ID
- Clone this repository:
git clone https://github.com/hostinger-bot/uploader
cd uploader-
Install dependencies:
npm install
-
Create a
.envfile in the project root and add your Telegram Bot Token and Chat ID:TELEGRAM_TOKEN=your-telegram-bot-token TELEGRAM_CHAT_ID=your-chat-id
-
Run the application in development mode:
npm start
-
For a production build:
npm run build
Note: Build files will be saved in the
distfolder. -
For dev run
npm run dev
-
Access the application in your browser: http://localhost:3000
-
Type
/startor something on your bot
- express: Web framework for Node.js.
- multer: Middleware for handling file uploads.
- axios: For making HTTP requests to the Telegram API.
- form-data: For uploading files to Telegram.
- sanitize-filename: To ensure safe file names.
- pug: Template engine for rendering HTML.
- express-rate-limit: To limit request rates.
- morgan: For HTTP request logging.
- dotenv: To load environment variables from
.env.
- Telegram Limitations: The Bot API has a 50MB file size limit. For files up to 2GB, you need to run a local Bot API server.
- Security: Never commit the
.envfile to a public repository. Ensure.envis listed in.gitignore. - Production Build: The
distfolder is included in Git for easy deployment. Runnpm run buildbefore deploying.
- Fork this repository.
- Create a feature branch: git checkout -b feature/feature-name
- Commit your changes: git commit -m "Add feature-name feature"
- Push to your branch: git push origin feature/feature-name
- Create a Pull Request on GitHub.
MIT License. See LICENSE file for details.