upload-post 1.0.0
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 +57 -0
- package/index.d.ts +28 -0
- package/index.js +60 -0
- package/package.json +26 -0
package/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Upload-Post Node.js Client
|
|
2
|
+
|
|
3
|
+
Official client library for [Upload-Post](https://www.upload-post.com) API - cross-platform social media video upload.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🚀 Simple video upload to multiple platforms
|
|
8
|
+
- 🔒 Secure API key authentication
|
|
9
|
+
- 📁 Supports all major video formats
|
|
10
|
+
- 📝 Automatic form data handling
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install upload-post
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
```javascript
|
|
21
|
+
import { UploadPost } from 'upload-post';
|
|
22
|
+
|
|
23
|
+
const uploader = new UploadPost('your-api-key-here');
|
|
24
|
+
|
|
25
|
+
// Upload video with options
|
|
26
|
+
const result = await uploader.upload('/path/to/video.mp4', {
|
|
27
|
+
title: 'My Awesome Video',
|
|
28
|
+
user: 'test-user',
|
|
29
|
+
platforms: ['tiktok'] // Currently supported platforms
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
console.log('Upload successful:', result);
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## API Documentation
|
|
36
|
+
|
|
37
|
+
### Constructor
|
|
38
|
+
`new UploadPost(apiKey: string)`
|
|
39
|
+
|
|
40
|
+
### upload()
|
|
41
|
+
`upload(videoPath: string, options: UploadOptions): Promise<object>`
|
|
42
|
+
|
|
43
|
+
#### Options
|
|
44
|
+
- `videoPath`: Path to video file (MP4, MOV, AVI, etc.)
|
|
45
|
+
- `options.title`: Video title
|
|
46
|
+
- `options.user`: User identifier
|
|
47
|
+
- `options.platforms`: Array of target platforms (currently supports 'tiktok')
|
|
48
|
+
|
|
49
|
+
## Error Handling
|
|
50
|
+
The library throws errors for:
|
|
51
|
+
- Missing required parameters
|
|
52
|
+
- File not found
|
|
53
|
+
- API request failures
|
|
54
|
+
- Invalid platform specifications
|
|
55
|
+
|
|
56
|
+
## License
|
|
57
|
+
MIT
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
declare module 'upload-post' {
|
|
2
|
+
export interface UploadOptions {
|
|
3
|
+
/** Video title */
|
|
4
|
+
title: string;
|
|
5
|
+
/** User identifier */
|
|
6
|
+
user: string;
|
|
7
|
+
/** Array of target platforms */
|
|
8
|
+
platforms: string[];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Upload-Post API client
|
|
13
|
+
*/
|
|
14
|
+
export class UploadPost {
|
|
15
|
+
/**
|
|
16
|
+
* @param apiKey - Your API key from Upload-Post
|
|
17
|
+
*/
|
|
18
|
+
constructor(apiKey: string);
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Upload video to social media platforms
|
|
22
|
+
* @param videoPath - Path to video file
|
|
23
|
+
* @param options - Upload options
|
|
24
|
+
* @returns Promise with API response
|
|
25
|
+
*/
|
|
26
|
+
upload(videoPath: string, options: UploadOptions): Promise<object>;
|
|
27
|
+
}
|
|
28
|
+
}
|
package/index.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import FormData from 'form-data';
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import { createReadStream } from 'fs';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {Object} UploadOptions
|
|
8
|
+
* @property {string} title - Video title
|
|
9
|
+
* @property {string} user - User identifier
|
|
10
|
+
* @property {string[]} platforms - Array of platforms (e.g. ['tiktok'])
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Upload-Post API client
|
|
15
|
+
*/
|
|
16
|
+
export class UploadPost {
|
|
17
|
+
/**
|
|
18
|
+
* @param {string} apiKey - Your API key from Upload-Post
|
|
19
|
+
*/
|
|
20
|
+
constructor(apiKey) {
|
|
21
|
+
this.apiKey = apiKey;
|
|
22
|
+
this.baseUrl = 'https://api.upload-post.com/api';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Upload video to social media platforms
|
|
27
|
+
* @param {string} videoPath - Path to video file
|
|
28
|
+
* @param {UploadOptions} options - Upload options
|
|
29
|
+
* @returns {Promise<Object>} API response
|
|
30
|
+
*/
|
|
31
|
+
async upload(videoPath, options) {
|
|
32
|
+
const form = new FormData();
|
|
33
|
+
|
|
34
|
+
form.append('video', createReadStream(videoPath));
|
|
35
|
+
form.append('title', options.title);
|
|
36
|
+
form.append('user', options.user);
|
|
37
|
+
options.platforms.forEach(platform => {
|
|
38
|
+
form.append('platform[]', platform);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
try {
|
|
42
|
+
const response = await axios.post(`${this.baseUrl}/upload`, form, {
|
|
43
|
+
headers: {
|
|
44
|
+
...form.getHeaders(),
|
|
45
|
+
'Authorization': `Apikey ${this.apiKey}`
|
|
46
|
+
},
|
|
47
|
+
maxContentLength: Infinity,
|
|
48
|
+
maxBodyLength: Infinity
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
if (response.status !== 200) {
|
|
52
|
+
throw new Error(`API request failed with status ${response.status}`);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return response.data;
|
|
56
|
+
} catch (error) {
|
|
57
|
+
throw new Error(`Upload failed: ${error.message}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "upload-post",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Official client library for Upload-Post API - cross-platform social media video upload",
|
|
5
|
+
"main": "index.d.ts",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
9
|
+
},
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"keywords": [
|
|
12
|
+
"social-media",
|
|
13
|
+
"video-upload",
|
|
14
|
+
"tiktok",
|
|
15
|
+
"instagram",
|
|
16
|
+
"api-client"
|
|
17
|
+
],
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"axios": "^1.6.2",
|
|
20
|
+
"form-data": "^4.0.0"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/node": "^20.11.0",
|
|
24
|
+
"typescript": "^5.3.3"
|
|
25
|
+
}
|
|
26
|
+
}
|