tmpbox.me 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +183 -61
- package/package.json +26 -2
package/README.md
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
# tmpbox.me
|
|
2
2
|
|
|
3
|
-
Official
|
|
3
|
+
Official Node.js SDK and CLI for uploading files to **TmpBox.me**.
|
|
4
4
|
|
|
5
5
|
- No account required for guest uploads
|
|
6
|
-
- Guest
|
|
7
|
-
- Logged-in
|
|
8
|
-
-
|
|
6
|
+
- Guest uploads up to **100MB**
|
|
7
|
+
- Logged-in users upload up to **500MB**
|
|
8
|
+
- Default expiration is **30 days**
|
|
9
|
+
- Supports CommonJS, ES Module, TypeScript and CLI
|
|
10
|
+
|
|
11
|
+
---
|
|
9
12
|
|
|
10
13
|
## Installation
|
|
11
14
|
|
|
@@ -13,40 +16,72 @@ Official TmpBox.me uploader SDK and CLI for Node.js.
|
|
|
13
16
|
npm install tmpbox.me
|
|
14
17
|
```
|
|
15
18
|
|
|
16
|
-
Node.js 18
|
|
19
|
+
Node.js **18+** is required.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
# Upload Limits
|
|
24
|
+
|
|
25
|
+
| Mode | Authentication | Max file size | Available TTL |
|
|
26
|
+
| ----- | ---------------------------- | ------------: | ---------------------------------------------------- |
|
|
27
|
+
| Guest | None | **100 MB** | `1d`, `7d`, `30d` _(default)_ |
|
|
28
|
+
| User | Username & Password or Token | **500 MB** | `1d`, `7d`, `30d` _(default)_, `0` _(Never expires)_ |
|
|
29
|
+
|
|
30
|
+
---
|
|
17
31
|
|
|
18
|
-
|
|
32
|
+
# Quick Start (Guest)
|
|
19
33
|
|
|
20
|
-
No
|
|
34
|
+
No account or token is required.
|
|
21
35
|
|
|
22
|
-
|
|
36
|
+
If no authentication is provided, uploads automatically use **Guest Mode**.
|
|
23
37
|
|
|
24
38
|
```js
|
|
25
|
-
|
|
39
|
+
import { uploadFile } from "tmpbox.me";
|
|
26
40
|
|
|
27
41
|
const result = await uploadFile("./video.mp4");
|
|
42
|
+
|
|
28
43
|
console.log(result.fullUrl);
|
|
29
44
|
```
|
|
30
45
|
|
|
31
|
-
|
|
46
|
+
CommonJS
|
|
32
47
|
|
|
33
48
|
```js
|
|
34
|
-
|
|
49
|
+
const { uploadFile } = require("tmpbox.me");
|
|
35
50
|
|
|
36
51
|
const result = await uploadFile("./video.mp4");
|
|
52
|
+
|
|
37
53
|
console.log(result.fullUrl);
|
|
38
54
|
```
|
|
39
55
|
|
|
40
|
-
Guest uploads
|
|
56
|
+
Guest uploads:
|
|
41
57
|
|
|
42
|
-
|
|
58
|
+
- Maximum file size: **100MB**
|
|
59
|
+
- Default TTL: **30 days**
|
|
60
|
+
- Supported TTL:
|
|
61
|
+
- `1d`
|
|
62
|
+
- `7d`
|
|
63
|
+
- `30d`
|
|
43
64
|
|
|
44
|
-
|
|
65
|
+
Example:
|
|
45
66
|
|
|
46
67
|
```js
|
|
47
68
|
import { uploadFile } from "tmpbox.me";
|
|
48
69
|
|
|
49
|
-
const result = await uploadFile("./
|
|
70
|
+
const result = await uploadFile("./photo.png", {
|
|
71
|
+
ttl: "7d",
|
|
72
|
+
});
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
# Login with Username & Password
|
|
78
|
+
|
|
79
|
+
Logged-in users can upload files up to **500MB**.
|
|
80
|
+
|
|
81
|
+
```js
|
|
82
|
+
import { uploadFile } from "tmpbox.me";
|
|
83
|
+
|
|
84
|
+
const result = await uploadFile("./movie.mp4", {
|
|
50
85
|
username: "your_username",
|
|
51
86
|
password: "your_password",
|
|
52
87
|
});
|
|
@@ -54,31 +89,48 @@ const result = await uploadFile("./large-video.mp4", {
|
|
|
54
89
|
console.log(result.fullUrl);
|
|
55
90
|
```
|
|
56
91
|
|
|
57
|
-
|
|
92
|
+
Default TTL:
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
30d
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Supported TTL:
|
|
99
|
+
|
|
100
|
+
- `1d`
|
|
101
|
+
- `7d`
|
|
102
|
+
- `30d`
|
|
103
|
+
- `0` _(Never expires)_
|
|
104
|
+
|
|
105
|
+
Example:
|
|
58
106
|
|
|
59
107
|
```js
|
|
60
108
|
import { uploadFile } from "tmpbox.me";
|
|
61
109
|
|
|
62
|
-
const result = await uploadFile("./
|
|
63
|
-
|
|
110
|
+
const result = await uploadFile("./backup.zip", {
|
|
111
|
+
username: "your_username",
|
|
112
|
+
password: "your_password",
|
|
113
|
+
ttl: "0",
|
|
64
114
|
});
|
|
65
115
|
```
|
|
66
116
|
|
|
67
|
-
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
# Upload with Access Token
|
|
120
|
+
|
|
121
|
+
If you already have an access token:
|
|
68
122
|
|
|
69
123
|
```js
|
|
70
124
|
import { uploadFile } from "tmpbox.me";
|
|
71
125
|
|
|
72
|
-
const result = await uploadFile("./
|
|
73
|
-
|
|
74
|
-
console.log(state.status, state.progress);
|
|
75
|
-
},
|
|
126
|
+
const result = await uploadFile("./video.mp4", {
|
|
127
|
+
token: "YOUR_ACCESS_TOKEN",
|
|
76
128
|
});
|
|
77
|
-
|
|
78
|
-
console.log(result.fullUrl);
|
|
79
129
|
```
|
|
80
130
|
|
|
81
|
-
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
# Upload Multiple Files
|
|
82
134
|
|
|
83
135
|
```js
|
|
84
136
|
import { uploadFiles } from "tmpbox.me";
|
|
@@ -89,117 +141,187 @@ const results = await uploadFiles([
|
|
|
89
141
|
"./archive.zip",
|
|
90
142
|
]);
|
|
91
143
|
|
|
92
|
-
console.log(results
|
|
144
|
+
console.log(results);
|
|
93
145
|
```
|
|
94
146
|
|
|
95
|
-
|
|
147
|
+
---
|
|
96
148
|
|
|
97
|
-
|
|
149
|
+
# Upload Progress
|
|
150
|
+
|
|
151
|
+
```js
|
|
152
|
+
import { uploadFile } from "tmpbox.me";
|
|
153
|
+
|
|
154
|
+
const result = await uploadFile("./video.mp4", {
|
|
155
|
+
onProgress(progress) {
|
|
156
|
+
console.log(progress.status);
|
|
157
|
+
console.log(progress.progress + "%");
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
# Default Behavior
|
|
165
|
+
|
|
166
|
+
If `ttl` is omitted, the SDK automatically uses:
|
|
167
|
+
|
|
168
|
+
```js
|
|
169
|
+
ttl: "30d";
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
If authentication is omitted, the SDK automatically uploads as a **Guest**.
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
# CLI
|
|
177
|
+
|
|
178
|
+
Guest upload
|
|
98
179
|
|
|
99
180
|
```bash
|
|
100
181
|
tmpbox-upload ./video.mp4
|
|
101
182
|
```
|
|
102
183
|
|
|
103
|
-
|
|
184
|
+
Login upload
|
|
104
185
|
|
|
105
186
|
```bash
|
|
106
|
-
tmpbox-upload ./video.mp4 -u
|
|
187
|
+
tmpbox-upload ./video.mp4 -u username -p password
|
|
107
188
|
```
|
|
108
189
|
|
|
109
|
-
|
|
190
|
+
Token upload
|
|
110
191
|
|
|
111
192
|
```bash
|
|
112
|
-
tmpbox-upload ./video.mp4 -t
|
|
193
|
+
tmpbox-upload ./video.mp4 -t YOUR_TOKEN
|
|
113
194
|
```
|
|
114
195
|
|
|
115
|
-
|
|
196
|
+
Multiple files
|
|
116
197
|
|
|
117
198
|
```bash
|
|
118
|
-
tmpbox-upload ./a.zip ./b.
|
|
199
|
+
tmpbox-upload ./a.zip ./b.mp4 ./c.pdf
|
|
119
200
|
```
|
|
120
201
|
|
|
121
|
-
|
|
202
|
+
JSON output
|
|
122
203
|
|
|
123
204
|
```bash
|
|
124
205
|
tmpbox-upload ./video.mp4 --json
|
|
125
206
|
```
|
|
126
207
|
|
|
127
|
-
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
# Environment Variables
|
|
128
211
|
|
|
129
|
-
|
|
212
|
+
Username & Password
|
|
130
213
|
|
|
131
214
|
```bash
|
|
132
215
|
TMPBOX_USERNAME=your_username
|
|
133
216
|
TMPBOX_PASSWORD=your_password
|
|
134
217
|
```
|
|
135
218
|
|
|
136
|
-
|
|
219
|
+
Token
|
|
137
220
|
|
|
138
221
|
```bash
|
|
139
|
-
TMPBOX_TOKEN=
|
|
222
|
+
TMPBOX_TOKEN=your_access_token
|
|
140
223
|
```
|
|
141
224
|
|
|
142
|
-
Legacy
|
|
225
|
+
Legacy variables are also supported:
|
|
143
226
|
|
|
144
227
|
```bash
|
|
145
228
|
FILESTORAGE_TOKEN=your_token
|
|
146
229
|
UPLOAD_TOKEN=your_token
|
|
147
230
|
```
|
|
148
231
|
|
|
149
|
-
|
|
232
|
+
---
|
|
150
233
|
|
|
151
|
-
|
|
234
|
+
# API
|
|
152
235
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
Uploads one file.
|
|
236
|
+
## uploadFile()
|
|
156
237
|
|
|
157
238
|
```ts
|
|
158
239
|
uploadFile(filePath: string, options?: UploadOptions): Promise<UploadResult>
|
|
159
240
|
```
|
|
160
241
|
|
|
161
|
-
|
|
242
|
+
Uploads a single file.
|
|
243
|
+
|
|
244
|
+
---
|
|
162
245
|
|
|
163
|
-
|
|
246
|
+
## uploadFiles()
|
|
164
247
|
|
|
165
248
|
```ts
|
|
166
|
-
uploadFiles(
|
|
249
|
+
uploadFiles(files: string[], options?: UploadOptions): Promise<UploadResult[]>
|
|
167
250
|
```
|
|
168
251
|
|
|
169
|
-
|
|
252
|
+
Uploads multiple files.
|
|
253
|
+
|
|
254
|
+
---
|
|
170
255
|
|
|
171
|
-
|
|
256
|
+
## login()
|
|
172
257
|
|
|
173
258
|
```ts
|
|
174
259
|
login(username: string, password: string): Promise<LoginResult>
|
|
175
260
|
```
|
|
176
261
|
|
|
177
|
-
|
|
262
|
+
Logs in and returns an access token.
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
# Options
|
|
178
267
|
|
|
179
268
|
```ts
|
|
180
269
|
interface UploadOptions {
|
|
181
270
|
token?: string;
|
|
271
|
+
|
|
182
272
|
username?: string;
|
|
273
|
+
|
|
183
274
|
password?: string;
|
|
184
|
-
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Default: "30d"
|
|
278
|
+
*
|
|
279
|
+
* Guest:
|
|
280
|
+
* - "1d"
|
|
281
|
+
* - "7d"
|
|
282
|
+
* - "30d"
|
|
283
|
+
*
|
|
284
|
+
* User:
|
|
285
|
+
* - "1d"
|
|
286
|
+
* - "7d"
|
|
287
|
+
* - "30d"
|
|
288
|
+
* - "0" (Never expires)
|
|
289
|
+
*/
|
|
290
|
+
ttl?: "1d" | "7d" | "30d" | "0";
|
|
291
|
+
|
|
185
292
|
filename?: string;
|
|
293
|
+
|
|
186
294
|
mimetype?: string;
|
|
295
|
+
|
|
187
296
|
chunkSize?: number;
|
|
188
|
-
|
|
297
|
+
|
|
189
298
|
wait?: boolean;
|
|
299
|
+
|
|
190
300
|
timeoutMs?: number;
|
|
301
|
+
|
|
191
302
|
pollIntervalMs?: number;
|
|
192
|
-
|
|
303
|
+
|
|
304
|
+
onProgress?: (progress: UploadProgress) => void;
|
|
193
305
|
}
|
|
194
306
|
```
|
|
195
307
|
|
|
196
|
-
|
|
308
|
+
---
|
|
309
|
+
|
|
310
|
+
# Features
|
|
311
|
+
|
|
312
|
+
- Guest uploads without registration
|
|
313
|
+
- Username & password authentication
|
|
314
|
+
- Token authentication
|
|
315
|
+
- Automatic retry
|
|
316
|
+
- Automatic polling
|
|
317
|
+
- Upload progress callback
|
|
318
|
+
- CommonJS support
|
|
319
|
+
- ES Module support
|
|
320
|
+
- TypeScript definitions
|
|
321
|
+
- CLI included
|
|
197
322
|
|
|
198
|
-
|
|
199
|
-
| ----- | -------------------------- | -------------- |
|
|
200
|
-
| Guest | No | 100MB per file |
|
|
201
|
-
| User | Username/password or token | 500MB per file |
|
|
323
|
+
---
|
|
202
324
|
|
|
203
|
-
|
|
325
|
+
# License
|
|
204
326
|
|
|
205
327
|
MIT
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tmpbox.me",
|
|
3
3
|
"author": "bangvn71",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.5",
|
|
5
5
|
"description": "Official TmpBox.me uploader SDK and CLI for Node.js.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./lib/index.cjs",
|
|
@@ -28,11 +28,35 @@
|
|
|
28
28
|
"pack:local": "npm pack"
|
|
29
29
|
},
|
|
30
30
|
"keywords": [
|
|
31
|
-
"tmpbox.me",
|
|
32
31
|
"tmpbox",
|
|
32
|
+
"tmpbox.me",
|
|
33
|
+
"tmpbox sdk",
|
|
34
|
+
"tmpbox api",
|
|
35
|
+
"tmpbox uploader",
|
|
33
36
|
"upload",
|
|
37
|
+
"uploader",
|
|
38
|
+
"upload sdk",
|
|
39
|
+
"file",
|
|
40
|
+
"file upload",
|
|
34
41
|
"file-upload",
|
|
35
42
|
"storage",
|
|
43
|
+
"cloud storage",
|
|
44
|
+
"temporary storage",
|
|
45
|
+
"temporary file",
|
|
46
|
+
"file hosting",
|
|
47
|
+
"share files",
|
|
48
|
+
"cdn",
|
|
49
|
+
"multipart",
|
|
50
|
+
"chunk upload",
|
|
51
|
+
"parallel upload",
|
|
52
|
+
"nodejs",
|
|
53
|
+
"node",
|
|
54
|
+
"javascript",
|
|
55
|
+
"typescript",
|
|
56
|
+
"esm",
|
|
57
|
+
"commonjs",
|
|
58
|
+
"sdk",
|
|
59
|
+
"api",
|
|
36
60
|
"cli"
|
|
37
61
|
],
|
|
38
62
|
"license": "MIT",
|