https://github.com/dreamdevil00/smart-uploader
A simple ftp uploader with queue management
https://github.com/dreamdevil00/smart-uploader
ftp queue uploader
Last synced: 8 months ago
JSON representation
A simple ftp uploader with queue management
- Host: GitHub
- URL: https://github.com/dreamdevil00/smart-uploader
- Owner: dreamdevil00
- License: mit
- Created: 2018-09-18T09:10:10.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-10-22T03:27:28.000Z (over 7 years ago)
- Last Synced: 2025-10-08T05:43:49.141Z (9 months ago)
- Topics: ftp, queue, uploader
- Language: TypeScript
- Size: 27.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# smart-uploader
A simple ftp uploader with queue management.
## Example
```
import {
Uploader,
ICredential,
Behavior,
FileItem,
IFileItem,
IProgress,
} from 'smart-uploader';
const cre: ICredential = {
host: '127.0.0.1',
port: 21,
user: 'uploader',
password: 'Passw0rd',
};
const uploader = new Uploader({ credentials: cre, behavior: Behavior.Cover });
uploader.onBeforeUploadItem = function before(item: FileItem | null) {
if (item) {
console.log('开始上传:', item.localPath);
}
};
uploader.onAfterUploadItem = function after(item: FileItem | null) {
if (item) {
console.log('上传完毕:', item.localPath);
}
};
uploader.onErrorUploadItem = function error(item: FileItem | null) {
if (item) {
console.log(`上传出错: ${item.localPath} ${item.error}`);
}
};
uploader.onConnectionError = function connectionError(error) {
console.log(`连接出错: ${error.message}`);
};
uploader.onProgress = function progress(pro: IProgress) {
console.log(`progress: `, pro);
};
const file: IFileItem = {
name: 'demo.exe',
localPath: 'E:\\demo\\demo.exe',
serverPath: '/demo.exe',
size: 4013920256,
isDirectory: false,
};
uploader.upload([file]);
```