Skip to content

Commit b5b45ad

Browse files
authored
Merge pull request #5 from maher-xubair/main
fixed
2 parents 83ad0df + 396dcef commit b5b45ad

File tree

5 files changed

+119
-12
lines changed

5 files changed

+119
-12
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.env

Procfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: npm start

README.md

Lines changed: 92 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,33 @@ cd MegaCDN
1111
npm install
1212
```
1313

14+
## Deployments
15+
16+
#### Deploy To Heroku
17+
1. *If You Don't Have a Heroku Account, [Create An Account](https://signup.heroku.com).*
18+
2. *Now Deploy To Heroku.* <br>
19+
[![Heroku](https://img.shields.io/badge/Heroku-000000?style=for-the-badge&logo=heroku&logoColor=white)](https://heroku.com/deploy?template=https://github.com/IRON-M4N/MegaCDN)
20+
21+
#### Deploy on Vercel
22+
1. *[Create Verce Account](https://vercel.com/signup) If You Don't Have.*
23+
2. *Deploy on Vercel.* <br>
24+
[![Vercel](https://img.shields.io/badge/Vercel-000000?style=for-the-badge&logo=vercel&logoColor=white)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2FIRON-M4N%2FMegaCDN&env=MEGA_ACCOUNT,PORT&envDescription=provide%20multiple%20accounts%20in%20this%20format%20email%3Apass%3Bemail%3Apass%0Afor%20port%20use%203000%20or%20any)
25+
26+
#### Deploy To Railway
27+
1. *If You Don't Have Railway Account, [Create First](https://railway.com).*
28+
2. *Now Deploy The Repo.* <br>
29+
[![Railway](https://img.shields.io/badge/Railway-000000?style=for-the-badge&logo=railway&logoColor=white)](https://railway.com/new)
30+
31+
#### Deploy on Render
32+
1. *[Create Render Account](https://dashboard.render.com/register) If You Don't Have Any.*
33+
2. *Deploy Now.* <br>
34+
[![Render](https://img.shields.io/badge/Render-000000?style=for-the-badge&logo=render&logoColor=white)](https://render.com/deploy?repo=https://github.com/IRON-M4N/MegaCDN)
35+
36+
#### Deploy on Koyeb
37+
1. *[Create Account](https://app.koyeb.com/auth/signup) If You Don't Have.*
38+
2. *Now Deploy.* <br>
39+
[![Koyeb](https://img.shields.io/badge/Koyeb-000000?style=for-the-badge&logo=koyeb&logoColor=white)](https://app.koyeb.com/deploy?type=git&repository=github.com/IRON-M4N/MegaCDN&name=MegaCDN&builder=buildpack&env[MEGA_ACCOUNT]=email:pass&env[PORT]=3000&env[TEMP]=memory )
40+
1441
## Configuration
1542

1643
Modify `config.js` or use environment variables. Example `.env` file:
@@ -32,21 +59,74 @@ npm stop
3259
npm restart
3360
```
3461

35-
## **Uploading Files**
62+
## Uploading Files
3663

37-
Send a `POST` request to `/upload` with a multipart form containing a file.
64+
Send a POST request to /upload with a multipart form containing a file.
3865

39-
#### **Single Mode (Default)**
40-
Uploads the file using the default (first) account.
41-
```sh
42-
curl -X POST -F "[email protected]" -F "mode=single" http://yourdomain.com/upload
43-
```
66+
<details>
67+
<summary>Curl - Single Mode</summary>
4468

45-
#### **Dual Mode (Specify Account)**
46-
Uploads the file to a specific account by providing an email.
47-
```sh
48-
curl -X POST -F "[email protected]" -F "mode=dual" -F "[email protected]" http://yourdomain.com/upload
49-
```
69+
``` sh
70+
curl -X POST -F "[email protected]" -F "mode=single" http://yourdomain.com/upload
71+
```
72+
</details>
73+
74+
<details>
75+
<summary>Curl - Dual Mode</summary>
76+
77+
```sh
78+
curl -X POST -F "[email protected]" -F "mode=dual" -F "[email protected]" http://yourdomain.com/upload
79+
```
80+
</details>
81+
82+
<details>
83+
<summary>Node.js - Single Mode</summary>
84+
85+
```js
86+
const fs = require("fs");
87+
const axios = require("axios");
88+
const FormData = require("form-data");
89+
90+
async function uploadSingle() {
91+
const form = new FormData();
92+
form.append("file", fs.createReadStream("image.jpg"));
93+
form.append("mode", "single");
94+
95+
const res = await axios.post("http://yourdomain.com/upload", form, {
96+
headers: form.getHeaders(),
97+
});
98+
99+
console.log(res.data);
100+
}
101+
102+
uploadSingle();
103+
```
104+
</details>
105+
106+
<details>
107+
<summary>Node.js - Dual Mode</summary>
108+
109+
```js
110+
const fs = require("fs");
111+
const axios = require("axios");
112+
const FormData = require("form-data");
113+
114+
async function uploadDual() {
115+
const form = new FormData();
116+
form.append("file", fs.createReadStream("image.jpg"));
117+
form.append("mode", "dual");
118+
form.append("email", "[email protected]");
119+
120+
const res = await axios.post("http://yourdomain.com/upload", form, {
121+
headers: form.getHeaders(),
122+
});
123+
124+
console.log(res.data);
125+
}
126+
127+
uploadDual();
128+
```
129+
</details>
50130

51131
### **Parameters Explained:**
52132
| Parameter | Description |

heroku.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
build:
2+
buildpacks:
3+
- heroku/nodejs
4+
5+
run:
6+
web: npm start
7+
8+
env:
9+
MEGA_ACCOUNT: email:pass;email:pass
10+
PORT: 3000
11+
TEMP: memory

render.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
services:
2+
- type: web
3+
name: megacdn
4+
env: node
5+
buildCommand: npm install
6+
startCommand: npm start
7+
plan: free # Change to 'starter' or 'pro' if needed
8+
envVars:
9+
- key: MEGA_ACCOUNT
10+
value: email:pass;email:pass
11+
- key: PORT
12+
value: 3000
13+
- key: TEMP
14+
value: memory

0 commit comments

Comments
 (0)