https://github.com/fischerscode/ftpconnect
A simple and robust dart FTP Client Library to interact with FTP Servers with possibility of zip and unzip files.
https://github.com/fischerscode/ftpconnect
Last synced: about 1 month ago
JSON representation
A simple and robust dart FTP Client Library to interact with FTP Servers with possibility of zip and unzip files.
- Host: GitHub
- URL: https://github.com/fischerscode/ftpconnect
- Owner: fischerscode
- License: mit
- Created: 2021-04-16T01:54:42.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-09T18:21:43.000Z (over 3 years ago)
- Last Synced: 2025-03-06T08:57:35.813Z (about 1 year ago)
- Language: Dart
- Size: 7.01 MB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
Flutter FTP Connect
Flutter simple and robust dart FTP Connect Library to interact with FTP Servers with possibility of zip and unzip files.
Key Features •
Examples •
License
## Key Features
* Upload files to FTP
* Download files/directories from FTP
* List FTP directory contents
* Manage FTP files (rename/delete)
* Manage file zipping/unzipping
* Completely asynchronous functions
## Example upload file
###example 1:
```dart
import 'dart:io';
import 'package:ftpconnect/ftpConnect.dart';
main() async{
FTPConnect ftpConnect = FTPConnect('example.com',user:'user', pass:'pass');
File fileToUpload = File('fileToUpload.txt');
await ftpConnect.connect();
bool res = await ftpConnect.uploadFileWithRetry(fileToUpload, pRetryCount: 2);
await ftpConnect.disconnect();
print(res);
}
```
###example 2: step by step
```dart
import 'dart:io';
import 'package:ftpconnect/ftpConnect.dart';
main() async{
FTPConnect ftpConnect = FTPConnect('example.com',user:'user', pass:'pass');
try {
File fileToUpload = File('fileToUpload.txt');
await ftpConnect.connect();
await ftpConnect.uploadFile(fileToUpload);
await ftpConnect.disconnect();
} catch (e) {
//error
}
}
```
## Download file
###example 1:
```dart
import 'dart:io';
import 'package:ftpconnect/ftpConnect.dart';
main() async{
FTPConnect ftpConnect = FTPConnect('example.com',user:'user', pass:'pass');
String fileName = 'toDownload.txt';
await ftpConnect.connect();
bool res = await ftpConnect.downloadFileWithRetry(fileName, File('myFileFromFTP.txt'));
await ftpConnect.disconnect();
print(res)
}
```
###example 2: step by step
```dart
import 'dart:io';
import 'package:ftpconnect/ftpConnect.dart';
main() {
FTPConnect ftpConnect = FTPConnect('example.com',user:'user', pass:'pass');
try {
String fileName = 'toDownload.txt';
await ftpConnect.connect();
await ftpConnect.downloadFile(fileName, File('myFileFromFTP.txt'));
await ftpConnect.disconnect();
} catch (e) {
//error
}
}
```
## Other Features
###Directory functions:
```dart
//Get directory content
ftpConnect.listDirectoryContent({LISTDIR_LIST_COMMAND cmd=LISTDIR_LIST_COMMAND.MLSD});
//Create directory
ftpConnect.makeDirectory('newDir');
//Change directory
ftpConnect.changeDirectory('moveHereDir');
//get current directory
ftpConnect.currentDirectory();
//Delete directory
ftpConnect.deleteDirectory('dirToDelete');
//check for directory existance
ftpConnect.checkFolderExistence('dirToCheck');
//create a directory if it does not exist
ftpConnect.createFolderIfNotExist('dirToCreate');
```
###File functions:
```dart
//rename file
ftpConnect.rename('test1.txt', 'test2.txt');
//file size
ftpConnect.sizeFile('test1.txt');
//file existence
ftpConnect.existFile('test1.txt');
//delete file
ftpConnect.deleteFile('test2.zip');
```
###Zip functions:
```dart
//compress a list of files/directories into Zip file
FTPConnect.zipFiles(List paths, String destinationZipFile);
//unzip a zip file
FTPConnect.unZipFile(File zipFile, String destinationPath, {password});
```
## Paramaters
| Properties | Description|
| ------------ | ------------ |
|`host`|Hostname or IP Address|
|`port`|Port number (Defaults to 21)|
|`user`|Username (Defaults to anonymous)|
|`pass`|Password if not anonymous login|
|`debug`|Enable Debug Logging|
|`timeout`|Timeout in seconds to wait for responses (Defaults to 30)|
# [View more Examples](https://github.com/salim-lachdhaf/ftpconnect/tree/master/example)
## License
MIT