パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v3.0.0

ftpconnect

FTP サーバーとやり取りするためのシンプルで堅牢な Dart FTP 接続ライブラリ。

AndroidiOSmacOSWindowsLinux
30日間ダウンロード
9470
いいね数
141
Pub ポイント
150

パッケージをインストール

flutter pub add ftpconnect

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

FTP サーバーに接続するためのシンプルで堅牢な Dart ライブラリであり、複数のプラットフォーム間でのスムーズなファイル転送を可能にします。リモート FTP サーバーとやり取りするための直感的な API を提供し、アップロード、ダウンロード、ファイル一覧表示、ディレクトリの管理などの一般的な操作をサポートしています。信頼性と使いやすさを重視して設計されており、Android、iOS、macOS、Windows、Linux 向けの Flutter アプリケーションにスムーズに統合できます。FTP を介したセキュアまたは自動化されたファイル処理が必要なアプリに最適です。

用途

  • アプリとFTPサーバー間のファイル転送
  • 自動バックアップシステム
  • アプリでのリモートファイル管理
  • FTPストレージとのアプリデータの同期
  • FTPから構成ファイルをダウンロードしています

主な機能

  • クロスプラットフォーム対応
  • シンプルで直感的な API
  • 堅牢なエラー処理
  • ファイルのアップロード/ダウンロードをサポート
  • ディレクトリのリスト表示とナビゲーション

適している対象

  • ファイル同期アプリを開発する開発者
  • リモートファイルアクセスを必要とするアプリ
  • FTPを使用するバックエンドサービス
  • FTPを介してファイルを管理するIoTデバイス
  • ネットワークプロトコルに関する教育プロジェクト

注意事項

  • 安定したインターネット接続が必要です
  • 組み込みの暗号化なし(必要に応じてFTPSを使用)
  • FTPプロトコルのみに制限
  • ファイアウォールの構成が必要になる場合があります
  • 追加措置が講じられない限り、高セキュリティ環境には適していません

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

Flutter FTP Connect

Flutter simple and robust dart FTP Connect Library to interact with FTP and SFTP Servers.

Key Features • Examples • Parameters • SFTP Support • License

Key Features

  • Supports SFTP/FTP/FTPS/FTPES
  • Upload files to the server
  • Download files/directories from the server
  • List directory contents
  • Manage files (rename/delete) and directories (create/delete)
  • Completely asynchronous functions

This library is originally based on dart_ftpclient, which has not been updated in years.

Example upload file

Example 1:
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.uploadFile(fileToUpload);
    await ftpConnect.disconnect();
    print(res);
}
Example 2: step by step
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:
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.downloadFile(fileName, File('myFileFromFTP.txt'));
    await ftpConnect.disconnect();
    print(res);
}
Example 2: step by step
import 'dart:io';
import 'package:ftpconnect/ftpconnect.dart';

main() async {
  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:
//Get directory content
ftpConnect.listDirectoryContent();

//Create directory
ftpConnect.makeDirectory('newDir');

//Change directory
ftpConnect.changeDirectory('moveHereDir');

//get current directory
ftpConnect.currentDirectory();

//Delete directory
ftpConnect.deleteDirectory('dirToDelete');

//Delete a non-empty directory (recursively)
ftpConnect.deleteNonEmptyDirectory('dirToDelete');

//check for directory existance
ftpConnect.checkFolderExistence('dirToCheck');

//create a directory if it does not exist
ftpConnect.createFolderIfNotExist('dirToCreate');

//Upload a local directory recursively to the server
ftpConnect.uploadDirectory(Directory('localDir'), 'remoteDir');

//Download a remote directory recursively
ftpConnect.downloadDirectory('remoteDir', Directory('localDir'));
File functions:
//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');

//upload in-memory bytes (no local file needed)
ftpConnect.uploadData(Uint8List.fromList([1, 2, 3]), 'remote.bin');

//download a remote file into memory as bytes
final Uint8List bytes = await ftpConnect.downloadToBytes('remote.bin');

Parameters

Common parameters (FTPConnect and SFTPConnect)
Property Description
host Hostname or IP Address
port Port number (FTP defaults to 21, FTPS to 990, SFTP to 22)
user Username (Defaults to anonymous)
pass Password if not anonymous login
showLog Enable Debug Logging (Defaults to false)
logger Custom logger
timeout Timeout in seconds to wait for responses (Defaults to 30)
FTP-only parameters (FTPConnect)
Property Description
securityType SecurityType.ftp / ftpes / ftps (Defaults to ftp)
SFTP-only parameters (SFTPConnect)
Property Description
privateKey PEM/OpenSSH private key content, used instead of pass
passphrase Passphrase protecting privateKey (if any)
onVerifyHostKey Optional host key verification handler

More details here.

SFTP support

SFTP is provided by the SFTPConnect class, powered by the pure-Dart dartssh2 package. Both FTPConnect and SFTPConnect implement the same FileTransferClient interface, so they share identical method names/signatures and you can swap one for the other by changing only the instantiated class.

ℹ️ dartssh2 is written in pure Dart, so SFTPConnect works on every platform supported by Dart/Flutter (except web, which has no raw TCP sockets).

import 'dart:io';
import 'package:ftpconnect/ftpconnect.dart';

main() async {
  SFTPConnect sftpConnect = SFTPConnect(
    'example.com',
    port: 22,
    user: 'user',
    pass: 'pass',
    showLog: true,
  );

  try {
    await sftpConnect.connect();

    // Upload a file
    File fileToUpload = File('fileToUpload.txt');
    await sftpConnect.uploadFile(fileToUpload);

    // List directory content
    List<FTPEntry> content = await sftpConnect.listDirectoryContent('.');
    print(content);

    // Download a file
    await sftpConnect.downloadFile('toDownload.txt', File('myFile.txt'));

    // Manage files/directories
    await sftpConnect.makeDirectory('newDir');
    await sftpConnect.rename('test1.txt', 'test2.txt');
    await sftpConnect.deleteFile('test2.txt');

    await sftpConnect.disconnect();
  } catch (e) {
    // error
  }
}

Authenticating with a private key instead of a password:

SFTPConnect sftpConnect = SFTPConnect(
  'example.com',
  user: 'user',
  privateKey: '''-----BEGIN RSA PRIVATE KEY-----
...
-----END RSA PRIVATE KEY-----''',
  passphrase: 'passphrase-for-key',
);

View more Examples

Support

If this plugin was useful to you, helped you to deliver your app, saved you a lot of time, or you just want to support the project, I would be very grateful if you buy me a cup of coffee.

Buy Me A Coffee

License

MIT

カテゴリー

依存関係

依存関係一覧 3 件

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。