Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
8287105
Add discord.js and fs to dependencies
Mirakud Apr 20, 2024
2de2bbb
Init discord bot
Mirakud Apr 20, 2024
8ab5d04
Login to BOT
Mirakud Apr 20, 2024
a502c7b
Essential function for fetching files from Discord server
Mirakud Apr 20, 2024
a345cf3
Add event ready
Mirakud Apr 20, 2024
8cc77c1
Verify if cache exist, create it if not, and update var :channel_msg_…
Mirakud Apr 20, 2024
e723cd1
if cache exist load it to the var: channel_msg_fetched
Mirakud Apr 20, 2024
74ed0ee
require fs and dotenv here
Mirakud Apr 20, 2024
ab01b7c
Update cache every 40min from Discord server
Mirakud Apr 20, 2024
2140f76
Get Url of each part from cache
Mirakud Apr 20, 2024
79c0a03
Add BOT_TOKEN, CHANNEL_ID, GUILD_ID
Mirakud Apr 20, 2024
740baa8
Support createdAt sort
Mirakud Apr 20, 2024
defa974
Add support for sorting by createdAt
Mirakud Apr 20, 2024
c98a3c6
increase the limit of fetched file on Discord server
Mirakud Apr 20, 2024
9a5ba8a
Update README > Section .env
Mirakud Apr 20, 2024
6c161a9
Other url in case of recently added file
Mirakud Apr 21, 2024
b2451c5
Add total size of files, div
Mirakud Apr 21, 2024
7244602
add count systeme for total size of files
Mirakud Apr 21, 2024
a9a0a61
add ? to catch error
Mirakud Apr 23, 2024
93294a1
Update README.md
Mirakud Jul 23, 2024
3a151e3
New VERSION v5.0.1 (faster download process: no bot)
Mirakud Jul 31, 2024
6ad58a4
New VERSION v5.0.1 (faster download process: no bot)
Mirakud Jul 31, 2024
ec339b4
New VERSION v5.0.1 (faster download process: no bot)
Mirakud Jul 31, 2024
5f10c94
chore: Update npm dependencies, including axios and dotenv
Mirakud Aug 12, 2024
be98e59
add npm install as a step of the guide
Mirakud Aug 12, 2024
6b4be15
Update .env_sample
Mirakud Feb 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 42 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,30 @@
</p>
<br>

# 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 ;)
<br><br><br>

##### **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.

https://user-images.githubusercontent.com/59018146/167635903-48cdace0-c383-4e7d-a037-4a32eaa4ab69.mp4

<!--
#### Current stable branch `4.x`

### Live demo at [ddrive.forscht.dev](https://ddrive.forscht.dev/)
### Live demo at [ddrive.forscht.dev](https://ddrive.forscht.dev/) -->

### Features

- Theoretically unlimited file size, thanks to splitting the file in 24mb chunks using nodejs streams API.
- Simple yet robust HTTP front end
- 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.

## New Version 4.0
<!-- ## New Version 4.0


This next major version release 4.0 is ddrive written from scratch. It comes with most requested features and several improvements.
Expand All @@ -59,32 +66,37 @@ This next major version release 4.0 is ddrive written from scratch. It comes wit
- DDrive now has proper rest API with OpenAPI 3.1 standards
- Added support for dark/light mode on panel

I spent several weeks finalizing this new version. Any support is highly appreciated - [Buy me a coffee](https://www.buymeacoffee.com/forscht)
I spent several weeks finalizing this new version. Any support is highly appreciated - [Buy me a coffee](https://www.buymeacoffee.com/forscht) -->

### 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](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks))
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 run migration:up`
7. Run - `node bin/ddrive`
8. Navigate to `http://localhost:3000` in your browser.
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

```shell
# config/.env

Expand All @@ -108,18 +120,39 @@ PUBLIC_ACCESS=READ_ONLY_FILE # If you want to give read only access to panel or
# 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
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)

[](https://github.com/ShufflePerson/Discord_CDN/blob/master/README.md#how-to-get-your-token)

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

```shell
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
```

<br/>
<br/>

_...see the [original repo](https://github.com/forscht/ddrive/) for the full readme_
Credit : Copyright 2024 ShufflePerson

<!--
### One Click Deploy with Railway
[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/new/template/tL53xa)

Expand Down Expand Up @@ -177,3 +210,4 @@ Migrating ddrive v3 to v4 is one way process once you migrate ddrive to v4 and a
Feel free to create [new issue](https://github.com/forscht/ddrive/issues/new) if it's not working for you or need any help.

[Discord Support server](https://discord.gg/3TCZRYafhW)
-->
6 changes: 5 additions & 1 deletion config/.env_sample
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# Required

DATABASE_URL=postgres://ddrive:[email protected]:5429/ddrive // Postgres DB URL
WEBHOOKS= // ',' seperated urls

# Optional

PORT=3000 // HTTP Server port
REQUEST_TIMEOUT=60000 // Request timeout - Increase if you have slow internet connection
CHUNK_SIZE=25165824 // 24MB - Can't increase. Webhooks are max allowed to 25MB
CHUNK_SIZE=10165824 // 10MB - Can't increase. Webhooks are max allowed to 10MB
SECRET=myrandomsecret // Put here something if you want to encrypt your files. May cause very high cpu usage
PUBLIC_ACCESS=READ_ONLY_FILE // ['READ_ONLY_FILE', 'READ_ONLY_PANEL'] Allow public user to access to download link of file or read only access of whole panel
AUTH=admin:admin
UPLOAD_CONCURRENCY=

USER_TOKEN= // Put real Discord User account Token (see README.md for steps)
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@forscht/ddrive",
"version": "4.3.0",
"version": "5.0.1",
"description": "A lightweight cloud storage system using discord as storage device written in nodejs",
"main": "src/index.js",
"author": "Darshan Patel <[email protected]> (https://github.com/forscht/ddrive)",
Expand Down Expand Up @@ -40,8 +40,10 @@
"@fastify/auth": "^4.2.0",
"@fastify/multipart": "^7.3.0",
"@fastify/static": "^6.6.0",
"dotenv": "^16.0.3",
"axios": "^1.7.3",
"dotenv": "^16.4.5",
"fastify": "^4.11.0",
"fs": "^0.0.1-security",
"knex": "^2.4.0",
"lodash": "^4.17.21",
"mime-types": "^2.1.35",
Expand Down
8 changes: 8 additions & 0 deletions src/DFs/cdn-package/Discord/Discord.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import IConfig from "../Types/IConfig";
declare class Discord {
private config;
constructor(config: IConfig);
fetchLatestLink(oldLink: string): Promise<string>;
private getHTTPConfig;
}
export default Discord;
58 changes: 58 additions & 0 deletions src/DFs/cdn-package/Discord/Discord.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/DFs/cdn-package/Discord/Discord.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/DFs/cdn-package/Discord/Types/ELinkIssue.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
declare enum ELinkIssue {
NONE = "",
INVALID_SLASH_AMOUNT = "Invalid link due to not the right amount of forward slashes",
CHANNEL_ID_NAN = "The Channel ID should be a valid integer.",
FILE_ID_NAN = "The File ID should be a valid integer.",
FILENAME_NO_DOT = "The File Name should include at least one dot."
}
export default ELinkIssue;
12 changes: 12 additions & 0 deletions src/DFs/cdn-package/Discord/Types/ELinkIssue.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/DFs/cdn-package/Discord/Types/ELinkIssue.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/DFs/cdn-package/Discord/Types/ETokenIssue.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
declare enum ETokenIssue {
NONE = "",
INVALID_AMOUNT_OF_DOTS = "The Token has an invalid amount of dots.",
NON_BASE64_UTF8 = "The ID part of the token is not valid",
ID_NOT_A_NUMBER = "THe ID part of the token is not a number",
ID_TOO_SHORT = "The ID part of the token is too short"
}
export default ETokenIssue;
12 changes: 12 additions & 0 deletions src/DFs/cdn-package/Discord/Types/ETokenIssue.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/DFs/cdn-package/Discord/Types/ETokenIssue.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/DFs/cdn-package/Discord/Types/ILinkData.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
interface ILinkData {
channelID: bigint;
fileID: bigint;
fileName: string;
}
export default ILinkData;
3 changes: 3 additions & 0 deletions src/DFs/cdn-package/Discord/Types/ILinkData.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/DFs/cdn-package/Discord/Types/ILinkData.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions src/DFs/cdn-package/Discord/Types/IParsedLink.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import ELinkIssue from "./ELinkIssue";
import ILinkData from "./ILinkData";
interface IParsedLink {
error: ELinkIssue;
data?: ILinkData;
}
export default IParsedLink;
3 changes: 3 additions & 0 deletions src/DFs/cdn-package/Discord/Types/IParsedLink.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/DFs/cdn-package/Discord/Types/IParsedLink.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions src/DFs/cdn-package/Discord/Types/IRefreshUrlsRes.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
interface IRefreshUrlsRes {
refreshed_urls: Array<{
original: string;
refreshed: string;
}>;
}
export default IRefreshUrlsRes;
3 changes: 3 additions & 0 deletions src/DFs/cdn-package/Discord/Types/IRefreshUrlsRes.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/DFs/cdn-package/Discord/Types/IRefreshUrlsRes.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/DFs/cdn-package/Discord/Utils/GetUTF8Base64.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare function GetUTF8Base64(input: string): string | null;
export default GetUTF8Base64;
19 changes: 19 additions & 0 deletions src/DFs/cdn-package/Discord/Utils/GetUTF8Base64.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/DFs/cdn-package/Discord/Utils/GetUTF8Base64.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/DFs/cdn-package/Discord/Utils/ParseLink.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import IParsedLink from "../Types/IParsedLink";
declare function ParseLink(input: string): IParsedLink;
export default ParseLink;
30 changes: 30 additions & 0 deletions src/DFs/cdn-package/Discord/Utils/ParseLink.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/DFs/cdn-package/Discord/Utils/ParseLink.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/DFs/cdn-package/Discord/Utils/VerifyToken.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare function VerifyToken(token: string, performStatic?: boolean): Promise<boolean>;
export default VerifyToken;
Loading