/ddrive4

Discord as a filesystem.

Primary LanguageJavaScriptMIT LicenseMIT

DDRIVE

Turn Discord into a datastore that can manage and store your files.

Discord server


This fork prevents files from becoming unavailable after 24 hours due to Discord's sharing restrictions. 😎

What's changing? Just add a user token to the .env ;)


DDrive A lightweight cloud storage system using discord as storage device written in nodejs. Supports an unlimited file size and unlimited storage, Implemented using node js streams with multi-part up & download.
ddrive_demo.mp4

Features

  • Theoretically unlimited file size, thanks to splitting the file in 24mb chunks using nodejs streams API.
  • Simple yet robust HTTP front end
  • Rest API with OpenAPI 3.1 specifications.
  • Tested with storing 4000 GB of data on single discord channel (With max file size of 16GB).
  • Supports basic auth with read only public access to panel.
  • Easily deployable on heroku/replit and use as private cloud storage.

Requirements

  • NodeJS v16.x or Docker
  • Postgres Database, Discord Webhook URLs
  • Avg technical knowledge

Setup Guide

  1. Clone this project
  2. Create few webhook urls. For better performance and to avoid rate limit at least create 5 with 1 webhook / text channel. (How to create webhook url)
  3. Setup postgres using docker, if you already don't have it running
    • cd .devcontainer
    • docker-compose up -d
  4. Copy config/.env_sample to config/.env and make necessary changes
  5. Optional - If you have lots of webhookURLs you can put those in webhook.txt with \n seperated.
  6. Run - npm install
  7. Run - npm run migration:up
  8. Run - node bin/ddrive
  9. Navigate to http://localhost:3000 in your browser.

How to keep it running forever

  1. Install pm2 with npm install -g pm2
  2. Run - pm2 start bin/ddrive
  3. Run - pm2 list to check status of ddrive
  4. Run - pm2 logs to check ddrive logs

Config variables explanation

# config/.env

# Required params
DATABASE_URL= # Database URL of postgres with valid postgres uri

WEBHOOKS={url1},{url2} # Webhook urls seperated by ","

# Optional params
PORT=3000 # HTTP Port where ddrive panel will start running

REQUEST_TIMEOUT=60000 # Time in ms after which ddrive will abort request to discord api server. Set it high if you have very slow internet

CHUNK_SIZE=25165824 # ChunkSize in bytes. You should probably never touch this and if you do  don't set it to more than 25MB, with discord webhooks you can't upload file bigger than 25MB

SECRET=someverysecuresecret # If you set this every files on discord will be stored using strong encryption, but it will cause significantly high cpu usage, so don't use it unless you're storing important stuff

AUTH=admin:admin # Username password seperated by ":". If you set this panel will ask for username password before access

PUBLIC_ACCESS=READ_ONLY_FILE # If you want to give read only access to panel or file use this option. Check below for valid options.
                             # READ_ONLY_FILE - User will be only access download links of file and not panel
                             # READ_ONLY_PANEL - User will be able to browse the panel for files/directories but won't be able to upload/delete/rename any file/folder.

UPLOAD_CONCURRENCY=3 # ddrive will upload this many chunks in parallel to discord. If you have fast internet increasing it will significantly increase performance at cost of cpu/disk usage

USER_TOKEN= # Put real Discord User account Token (see below for steps)

How to get a user Discord token (need to be login to the account)

  1. Open Discord on your Browser.
  2. Open the Dev Tools ( Inspect Element )
  3. Go to the Console Tab and paste in the following command
  4. console.log((webpackChunkdiscord_app.push([[''],{},e=>{m=[];for(let c in e.c)m.push(e.c[c])}]),m).find(m=>m?.exports?.default?.getToken!==void 0).exports.default.getToken());
  5. Copy the output and set it in the .env file. (e.g USER_TOKEN=PASTE_TOKEN_HERE), the account does not have to be on your ddrive server

Run using docker

docker run -rm -it -p 8080:8080 \
-e PORT=8080 \
-e WEBHOOKS={url1},{url2} \
-e DATABASE_URL={database url} \
-e USER_TOKEN=PASTE_TOKEN_HERE \
--name ddrive forscht/ddrive


...see the original repo for the full readme Credit : Copyright 2024 ShufflePerson