### Get File Size Source: https://context7.com/fischerscode/ftpconnect/llms.txt Returns the size of a file in bytes. Returns -1 if the file does not exist. ```APIDOC ## SIZE FILE ### Description Returns the size of a file in bytes. Returns -1 if the file does not exist. ### Method POST (or equivalent FTP command) ### Endpoint Not applicable (method on an existing connection) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```dart await ftpConnect.sizeFile('large_file.zip'); ``` ### Response #### Success Response (200) - **fileSize** (integer) - The size of the file in bytes, or -1 if the file does not exist. #### Response Example ```json { "fileSize": 1048576 } ``` ``` -------------------------------- ### Get File Size on FTP Server Source: https://context7.com/fischerscode/ftpconnect/llms.txt Retrieves the size of a file in bytes. Returns -1 if the file is not found. Requires an active FTP connection. ```dart import 'package:ftpconnect/ftpconnect.dart'; void main() async { FTPConnect ftpConnect = FTPConnect('ftp.example.com', user: 'user', pass: 'pass'); try { await ftpConnect.connect(); int fileSize = await ftpConnect.sizeFile('large_file.zip'); if (fileSize != -1) { double sizeMB = fileSize / (1024 * 1024); print('File size: ${sizeMB.toStringAsFixed(2)} MB'); } else { print('File does not exist'); } await ftpConnect.disconnect(); } catch (e) { print('Error: ${e.toString()}'); } } ``` -------------------------------- ### Get Current FTP Directory Source: https://context7.com/fischerscode/ftpconnect/llms.txt The `currentDirectory` function returns the absolute path of the current working directory on the FTP server. It's useful for verifying your location after changing directories. ```dart import 'package:ftpconnect/ftpconnect.dart'; void main() async { FTPConnect ftpConnect = FTPConnect('ftp.example.com', user: 'user', pass: 'pass'); try { await ftpConnect.connect(); String currentDir = await ftpConnect.currentDirectory(); print('Current directory: $currentDir'); // Output: /home/user await ftpConnect.changeDirectory('uploads'); currentDir = await ftpConnect.currentDirectory(); print('Current directory: $currentDir'); // Output: /home/user/uploads await ftpConnect.disconnect(); } catch (e) { print('Error: ${e.toString()}'); } } ``` -------------------------------- ### connect Source: https://context7.com/fischerscode/ftpconnect/llms.txt Establishes a connection to the FTP server. ```APIDOC ## connect ### Description Establishes a connection to the FTP server using the credentials provided in the constructor. Must be called before any FTP operations. ### Response - **bool** - Returns true if the connection is successful. ``` -------------------------------- ### Initialize FTPConnect Client Source: https://context7.com/fischerscode/ftpconnect/llms.txt Instantiate the FTP client with server details, credentials, and optional configuration like debug mode and timeouts. ```dart import 'dart:io'; import 'package:ftpconnect/ftpconnect.dart'; // Basic connection with credentials FTPConnect ftpConnect = FTPConnect( 'ftp.example.com', port: 21, // Default FTP port user: 'username', pass: 'password', debug: true, // Enable debug logging timeout: 30 // Timeout in seconds ); // Anonymous connection FTPConnect ftpAnonymous = FTPConnect( 'ftp.example.com', user: 'anonymous', pass: 'anonymous' ); ``` -------------------------------- ### Perform Complete FTP Workflow with Compression Source: https://context7.com/fischerscode/ftpconnect/llms.txt Demonstrates a full cycle of compressing local files, uploading to an FTP server with retries, listing directory contents, and downloading/extracting files. ```dart import 'dart:io'; import 'package:ftpconnect/ftpconnect.dart'; void main() async { FTPConnect ftpConnect = FTPConnect( 'ftp.example.com', user: 'username', pass: 'password', debug: true ); try { // 1. Compress local files print('Compressing files...'); List filesToUpload = [ '/local/documents/report.pdf', '/local/images/photo.jpg' ]; String localZip = '/local/temp/upload_package.zip'; await FTPConnect.zipFiles(filesToUpload, localZip); // 2. Connect and upload print('Connecting to FTP server...'); await ftpConnect.connect(); // 3. Create target directory if needed await ftpConnect.createFolderIfNotExist('backups'); await ftpConnect.changeDirectory('backups'); // 4. Upload with retry print('Uploading...'); bool uploadSuccess = await ftpConnect.uploadFileWithRetry( File(localZip), pRetryCount: 3 ); print('Upload: ${uploadSuccess ? "SUCCESS" : "FAILED"}'); // 5. List directory to verify List contents = await ftpConnect.listDirectoryContent(); print('Server directory contents:'); for (var entry in contents) { print(' ${entry.type == FTPEntryType.DIR ? "[DIR]" : "[FILE]"} ${entry.name}'); } // 6. Download a file print('Downloading...'); File downloadedZip = File('/local/downloads/retrieved.zip'); bool downloadSuccess = await ftpConnect.downloadFileWithRetry( 'upload_package.zip', downloadedZip, pRetryCount: 2 ); // 7. Extract downloaded file if (downloadSuccess) { print('Extracting...'); List extracted = await FTPConnect.unZipFile( downloadedZip, '/local/downloads/extracted' ); print('Extracted ${extracted.length} files'); } // 8. Cleanup and disconnect await ftpConnect.disconnect(); print('Operation completed successfully'); } catch (e) { print('Error: ${e.toString()}'); } } ``` -------------------------------- ### FTPConnect Constructor Source: https://context7.com/fischerscode/ftpconnect/llms.txt Initializes a new FTP client instance with server details and authentication credentials. ```APIDOC ## FTPConnect Constructor ### Description Creates a new FTP client instance with connection parameters. The client supports anonymous and authenticated connections with configurable timeout and debug logging. ### Parameters - **host** (String) - Required - The FTP server address. - **port** (int) - Optional - The FTP port (default 21). - **user** (String) - Optional - Username for authentication. - **pass** (String) - Optional - Password for authentication. - **debug** (bool) - Optional - Enable debug logging. - **timeout** (int) - Optional - Timeout in seconds. ``` -------------------------------- ### Connect to FTP Server Source: https://context7.com/fischerscode/ftpconnect/llms.txt Establish a connection to the server before performing any operations. Always wrap in a try-catch block to handle potential connection errors. ```dart import 'dart:io'; import 'package:ftpconnect/ftpconnect.dart'; void main() async { FTPConnect ftpConnect = FTPConnect('ftp.example.com', user: 'user', pass: 'pass'); try { bool connected = await ftpConnect.connect(); print('Connected: $connected'); // Output: Connected: true } catch (e) { print('Connection failed: ${e.toString()}'); } } ``` -------------------------------- ### Manage FTP directories Source: https://github.com/fischerscode/ftpconnect/blob/master/README.md Provides methods for listing, creating, changing, and deleting directories on the FTP server. ```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'); ``` -------------------------------- ### createFolderIfNotExist Source: https://context7.com/fischerscode/ftpconnect/llms.txt Creates a directory only if it does not already exist. Returns true if the directory exists or was created successfully. ```APIDOC ## createFolderIfNotExist ### Description Creates a directory only if it does not already exist. Returns true if the directory exists or was created successfully. ### Method POST (or similar, depending on FTP command implementation) ### Endpoint Not applicable (method call on an object) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```dart bool result = await ftpConnect.createFolderIfNotExist('uploads'); ``` ### Response #### Success Response (200) - **result** (boolean) - True if the directory exists or was created successfully, false otherwise. #### Response Example ```json { "result": true } ``` ``` -------------------------------- ### Create New Directory on FTP Server Source: https://context7.com/fischerscode/ftpconnect/llms.txt Use `makeDirectory` to create a new directory within the current working directory. It returns true if the directory was created successfully. Nested structures can be created by chaining calls. ```dart import 'package:ftpconnect/ftpconnect.dart'; void main() async { FTPConnect ftpConnect = FTPConnect('ftp.example.com', user: 'user', pass: 'pass'); try { await ftpConnect.connect(); bool created = await ftpConnect.makeDirectory('new_folder'); print('Directory created: $created'); // Output: Directory created: true // Create nested structure await ftpConnect.makeDirectory('backups'); await ftpConnect.changeDirectory('backups'); await ftpConnect.makeDirectory('2024'); await ftpConnect.disconnect(); } catch (e) { print('Error: ${e.toString()}'); } } ``` -------------------------------- ### makeDirectory Source: https://context7.com/fischerscode/ftpconnect/llms.txt Creates a new directory in the current working directory on the FTP server. Can be used to create nested structures. ```APIDOC ## makeDirectory ### Description Creates a new directory in the current working directory on the FTP server. ### Method POST (or similar, depending on FTP command implementation) ### Endpoint Not applicable (method call on an object) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```dart await ftpConnect.makeDirectory('new_folder'); await ftpConnect.makeDirectory('backups/2024'); // Creates nested structure if parent exists ``` ### Response #### Success Response (200) - **created** (boolean) - True if the directory was created successfully, false otherwise. #### Response Example ```json { "created": true } ``` ``` -------------------------------- ### Download a file from FTP Source: https://github.com/fischerscode/ftpconnect/blob/master/README.md Demonstrates downloading a file using retry logic or a standard try-catch block. ```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) } ``` ```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 } } ``` -------------------------------- ### downloadDirectory Source: https://context7.com/fischerscode/ftpconnect/llms.txt Downloads an entire remote directory recursively to a local directory. ```APIDOC ## downloadDirectory ### Description Downloads an entire remote directory recursively, including all files and subdirectories, to a local directory. ### Parameters #### Request Body - **remoteDir** (String) - Required - The path of the directory on the remote server. - **localDir** (Directory) - Required - The local directory object to save the contents to. - **cmd** (DIR_LIST_COMMAND) - Optional - The command used for listing (e.g., MLSD). - **pRetryCount** (int) - Optional - Number of retry attempts. ``` -------------------------------- ### Create FTP Folder If Not Exists Source: https://context7.com/fischerscode/ftpconnect/llms.txt Use `createFolderIfNotExist` to create a directory only if it doesn't already exist. This function is safe to call multiple times and returns true if the directory exists or was successfully created. ```dart import 'package:ftpconnect/ftpconnect.dart'; void main() async { FTPConnect ftpConnect = FTPConnect('ftp.example.com', user: 'user', pass: 'pass'); try { await ftpConnect.connect(); // Create folder if it doesn't exist bool result = await ftpConnect.createFolderIfNotExist('uploads'); print('Folder ready: $result'); // Output: Folder ready: true // Safe to call multiple times - won't fail if exists result = await ftpConnect.createFolderIfNotExist('uploads'); print('Folder ready: $result'); // Output: Folder ready: true await ftpConnect.disconnect(); } catch (e) { print('Error: ${e.toString()}'); } } ``` -------------------------------- ### Compress Files into ZIP Archive (Static) Source: https://context7.com/fischerscode/ftpconnect/llms.txt A static utility method to compress multiple specified files and directories into a single ZIP archive. Ensure all paths are correct. ```dart import 'dart:io'; import 'package:ftpconnect/ftpconnect.dart'; void main() async { // Define paths to compress List pathsToZip = [ '/path/to/document.pdf', '/path/to/image.png', '/path/to/folder_to_include' ]; String zipDestination = '/path/to/output/archive.zip'; try { bool success = await FTPConnect.zipFiles(pathsToZip, zipDestination); print('Compression successful: $success'); print('ZIP file created at: $zipDestination'); } catch (e) { print('Compression error: ${e.toString()}'); } } ``` -------------------------------- ### Upload a file to FTP Source: https://github.com/fischerscode/ftpconnect/blob/master/README.md Demonstrates uploading a file using retry logic or a standard try-catch block. ```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); } ``` ```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 } } ``` -------------------------------- ### List Directory Content with Details Source: https://context7.com/fischerscode/ftpconnect/llms.txt Lists the contents of the current directory on the FTP server, returning detailed FTPEntry objects. Supports MLSD (preferred) or LIST commands. ```dart import 'package:ftpconnect/ftpconnect.dart'; void main() async { FTPConnect ftpConnect = FTPConnect('ftp.example.com', user: 'user', pass: 'pass'); try { await ftpConnect.connect(); // Use MLSD command (preferred for most servers) List contents = await ftpConnect.listDirectoryContent( cmd: DIR_LIST_COMMAND.MLSD ); // Alternative: Use LIST command for servers not supporting MLSD // List contents = await ftpConnect.listDirectoryContent( // cmd: DIR_LIST_COMMAND.LIST // ); for (FTPEntry entry in contents) { String type = entry.type == FTPEntryType.DIR ? '[DIR]' : '[FILE]'; print('$type ${entry.name} - Size: ${entry.size} bytes'); print(' Modified: ${entry.modifyTime}'); print(' Owner: ${entry.owner}, Group: ${entry.group}'); } await ftpConnect.disconnect(); } catch (e) { print('Error: ${e.toString()}'); } } ``` -------------------------------- ### listDirectoryContentOnlyNames Source: https://context7.com/fischerscode/ftpconnect/llms.txt Returns a simple list of file and directory names in the current directory. ```APIDOC ## listDirectoryContentOnlyNames ### Description Returns a simple list of file and directory names in the current directory without detailed metadata. ``` -------------------------------- ### Change Directory on FTP Server Source: https://context7.com/fischerscode/ftpconnect/llms.txt Use `changeDirectory` to navigate into subdirectories, to parent directories using '..', or to the root directory using '/'. It returns a boolean indicating success. ```dart import 'package:ftpconnect/ftpconnect.dart'; void main() async { FTPConnect ftpConnect = FTPConnect('ftp.example.com', user: 'user', pass: 'pass'); try { await ftpConnect.connect(); // Navigate into a subdirectory bool changed = await ftpConnect.changeDirectory('uploads'); print('Changed to uploads: $changed'); // Navigate to nested directory await ftpConnect.changeDirectory('2024/january'); // Navigate back to parent await ftpConnect.changeDirectory('..'); // Navigate to root await ftpConnect.changeDirectory('/'); await ftpConnect.disconnect(); } catch (e) { print('Error: ${e.toString()}'); } } ``` -------------------------------- ### Download File with Progress Callback Source: https://context7.com/fischerscode/ftpconnect/llms.txt Downloads a remote file to a local file with support for binary/ASCII modes and an optional progress callback. Ensure the local file path is valid. ```dart import 'dart:io'; import 'package:ftpconnect/ftpconnect.dart'; void main() async { FTPConnect ftpConnect = FTPConnect('ftp.example.com', user: 'user', pass: 'pass'); try { await ftpConnect.connect(); String remoteFileName = 'remote_file.zip'; File localFile = File('/path/to/save/downloaded_file.zip'); bool success = await ftpConnect.downloadFile( remoteFileName, localFile, mode: TransferMode.binary, onProgress: (progress) { print('Download progress: ${(progress * 100).toStringAsFixed(1)}%'); } ); print('Download successful: $success'); print('Saved to: ${localFile.path}'); await ftpConnect.disconnect(); } catch (e) { print('Download error: ${e.toString()}'); } } ``` -------------------------------- ### uploadFile Source: https://context7.com/fischerscode/ftpconnect/llms.txt Uploads a local file to the FTP server. ```APIDOC ## uploadFile ### Description Uploads a local file to the current directory on the FTP server. Supports both ASCII and binary transfer modes with optional progress callback. ### Parameters - **fileToUpload** (File) - Required - The local file to upload. - **sRemoteName** (String) - Optional - Custom name for the file on the server. - **mode** (TransferMode) - Optional - Transfer mode (ASCII or binary). - **onProgress** (Function) - Optional - Callback function for upload progress tracking. ### Response - **bool** - Returns true if the upload is successful. ``` -------------------------------- ### Zip Files (Static) Source: https://context7.com/fischerscode/ftpconnect/llms.txt Static utility method that compresses multiple files and directories into a single ZIP archive. ```APIDOC ## ZIP FILES (STATIC) ### Description Static utility method that compresses multiple files and directories into a single ZIP archive. ### Method POST (or equivalent FTP command) ### Endpoint Not applicable (static method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```dart List pathsToZip = [ '/path/to/document.pdf', '/path/to/image.png', '/path/to/folder_to_include' ]; String zipDestination = '/path/to/output/archive.zip'; await FTPConnect.zipFiles(pathsToZip, zipDestination); ``` ### Response #### Success Response (200) - **success** (boolean) - True if the compression was successful, false otherwise. #### Response Example ```json { "success": true } ``` ``` -------------------------------- ### checkFolderExistence Source: https://context7.com/fischerscode/ftpconnect/llms.txt Checks whether a directory exists on the FTP server by attempting to change to that directory. ```APIDOC ## checkFolderExistence ### Description Checks whether a directory exists on the FTP server by attempting to change to that directory. ### Method GET (or similar, depending on FTP command implementation) ### Endpoint Not applicable (method call on an object) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```dart bool exists = await ftpConnect.checkFolderExistence('uploads'); ``` ### Response #### Success Response (200) - **exists** (boolean) - True if the directory exists, false otherwise. #### Response Example ```json { "exists": true } ``` ``` -------------------------------- ### Manage FTP files Source: https://github.com/fischerscode/ftpconnect/blob/master/README.md Provides methods for renaming, checking size, verifying existence, and deleting files. ```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'); ``` -------------------------------- ### Check FTP Folder Existence Source: https://context7.com/fischerscode/ftpconnect/llms.txt The `checkFolderExistence` function verifies if a directory exists on the FTP server by attempting to change into it. It returns true if the directory exists and is accessible. ```dart import 'package:ftpconnect/ftpconnect.dart'; void main() async { FTPConnect ftpConnect = FTPConnect('ftp.example.com', user: 'user', pass: 'pass'); try { await ftpConnect.connect(); bool exists = await ftpConnect.checkFolderExistence('uploads'); print('uploads folder exists: $exists'); exists = await ftpConnect.checkFolderExistence('nonexistent_folder'); print('nonexistent_folder exists: $exists'); // Output: false await ftpConnect.disconnect(); } catch (e) { print('Error: ${e.toString()}'); } } ``` -------------------------------- ### listDirectoryContent Source: https://context7.com/fischerscode/ftpconnect/llms.txt Lists the contents of the current directory on the FTP server with detailed metadata. ```APIDOC ## listDirectoryContent ### Description Lists the contents of the current directory on the FTP server, returning detailed information about each file and folder as FTPEntry objects. ### Parameters #### Request Body - **cmd** (DIR_LIST_COMMAND) - Optional - The command used for listing (e.g., MLSD or LIST). ``` -------------------------------- ### List Directory Content Names Only Source: https://context7.com/fischerscode/ftpconnect/llms.txt Returns a simple list of file and directory names within the current directory, without any metadata. Useful for quick checks of directory contents. ```dart import 'package:ftpconnect/ftpconnect.dart'; void main() async { FTPConnect ftpConnect = FTPConnect('ftp.example.com', user: 'user', pass: 'pass'); try { await ftpConnect.connect(); List names = await ftpConnect.listDirectoryContentOnlyNames(); print('Directory contents:'); for (String name in names) { print(' - $name'); } // Output: // Directory contents: // - documents // - images // - readme.txt // - data.json await ftpConnect.disconnect(); } catch (e) { print('Error: ${e.toString()}'); } } ``` -------------------------------- ### Unzip File (Static) Source: https://context7.com/fischerscode/ftpconnect/llms.txt Static utility method that extracts a ZIP archive to a specified directory. Supports password-protected ZIP files. ```APIDOC ## UNZIP FILE (STATIC) ### Description Static utility method that extracts a ZIP archive to a specified directory. Supports password-protected ZIP files. ### Method POST (or equivalent FTP command) ### Endpoint Not applicable (static method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```dart File zipFile = File('/path/to/archive.zip'); String extractPath = '/path/to/extract/destination'; await FTPConnect.unZipFile(zipFile, extractPath); // With password await FTPConnect.unZipFile( File('/path/to/protected.zip'), extractPath, password: 'secretPassword123' ); ``` ### Response #### Success Response (200) - **extractedPaths** (List) - A list of paths to the extracted files. #### Response Example ```json { "extractedPaths": [ "/path/to/extract/destination/file1.txt", "/path/to/extract/destination/folder/file2.txt" ] } ``` ``` -------------------------------- ### Download Entire Directory Recursively Source: https://context7.com/fischerscode/ftpconnect/llms.txt Downloads an entire remote directory, including subdirectories and files, to a local directory. Supports retry mechanism and MLSD command for detailed listing. ```dart import 'dart:io'; import 'package:ftpconnect/ftpconnect.dart'; void main() async { FTPConnect ftpConnect = FTPConnect('ftp.example.com', user: 'user', pass: 'pass'); try { await ftpConnect.connect(); String remoteDir = 'remote_folder'; Directory localDir = Directory('/path/to/local/backup'); // Download entire directory with retry support bool success = await ftpConnect.downloadDirectory( remoteDir, localDir, cmd: DIR_LIST_COMMAND.MLSD, // Use MLSD for detailed listing pRetryCount: 2 ); print('Directory download: ${success ? "SUCCESSFUL" : "FAILED"}'); await ftpConnect.disconnect(); } catch (e) { print('Error: ${e.toString()}'); } } ``` -------------------------------- ### Upload Files to Server Source: https://context7.com/fischerscode/ftpconnect/llms.txt Upload local files using standard or binary transfer modes, with support for custom remote naming and progress tracking. ```dart import 'dart:io'; import 'package:ftpconnect/ftpconnect.dart'; void main() async { FTPConnect ftpConnect = FTPConnect('ftp.example.com', user: 'user', pass: 'pass'); try { await ftpConnect.connect(); File fileToUpload = File('/path/to/local/document.pdf'); // Upload with default name (same as local file) bool success = await ftpConnect.uploadFile(fileToUpload); // Upload with custom remote name and progress tracking bool result = await ftpConnect.uploadFile( fileToUpload, sRemoteName: 'renamed_document.pdf', mode: TransferMode.binary, onProgress: (progress) { print('Upload progress: ${(progress * 100).toStringAsFixed(1)}%'); } ); print('Upload successful: $result'); await ftpConnect.disconnect(); } catch (e) { print('Upload error: ${e.toString()}'); } } ``` -------------------------------- ### downloadFile Source: https://context7.com/fischerscode/ftpconnect/llms.txt Downloads a remote file from the FTP server to a local file with support for transfer modes and progress tracking. ```APIDOC ## downloadFile ### Description Downloads a remote file from the FTP server to a local file. Supports ASCII and binary transfer modes with optional progress callback. ### Parameters #### Request Body - **remoteFileName** (String) - Required - The name of the file on the remote server. - **localFile** (File) - Required - The local file object to save the data to. - **mode** (TransferMode) - Optional - The transfer mode (e.g., TransferMode.binary). - **onProgress** (Function) - Optional - Callback function to track download progress. ``` -------------------------------- ### uploadFileWithRetry Source: https://context7.com/fischerscode/ftpconnect/llms.txt Uploads a file with automatic retry logic. ```APIDOC ## uploadFileWithRetry ### Description Uploads a file with automatic retry mechanism for handling unreliable connections. ### Parameters - **fileToUpload** (File) - Required - The local file to upload. - **pRemoteName** (String) - Optional - Custom name for the file on the server. - **pRetryCount** (int) - Optional - Number of retry attempts on failure. ### Response - **bool** - Returns true if the upload is successful after retries. ``` -------------------------------- ### Extract ZIP Archive (Static) Source: https://context7.com/fischerscode/ftpconnect/llms.txt A static utility method to extract a ZIP archive to a specified directory. Supports password-protected archives. ```dart import 'dart:io'; import 'package:ftpconnect/ftpconnect.dart'; void main() async { File zipFile = File('/path/to/archive.zip'); String extractPath = '/path/to/extract/destination'; try { // Extract without password List extractedPaths = await FTPConnect.unZipFile( zipFile, extractPath ); print('Extracted files:'); for (String path in extractedPaths) { print(' - $path'); } // Extract password-protected ZIP List protectedPaths = await FTPConnect.unZipFile( File('/path/to/protected.zip'), extractPath, password: 'secretPassword123' ); print('Protected archive extracted: ${protectedPaths.length} items'); } catch (e) { print('Extraction error: ${e.toString()}'); } } ``` -------------------------------- ### downloadFileWithRetry Source: https://context7.com/fischerscode/ftpconnect/llms.txt Downloads a remote file with an automatic retry mechanism for handling connection failures. ```APIDOC ## downloadFileWithRetry ### Description Downloads a remote file with automatic retry mechanism for handling connection failures gracefully. ### Parameters #### Request Body - **remoteFile** (String) - Required - The name of the file on the remote server. - **localFile** (File) - Required - The local file object to save the data to. - **pRetryCount** (int) - Optional - Number of retry attempts. ``` -------------------------------- ### Zip and unzip files Source: https://github.com/fischerscode/ftpconnect/blob/master/README.md Provides static methods to compress files into a zip archive or extract files from a zip archive. ```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}); ``` -------------------------------- ### Check File Existence Source: https://context7.com/fischerscode/ftpconnect/llms.txt Checks if a file exists on the FTP server. ```APIDOC ## EXIST FILE ### Description Checks whether a file exists on the FTP server. ### Method POST (or equivalent FTP command) ### Endpoint Not applicable (method on an existing connection) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```dart await ftpConnect.existFile('important_file.txt'); ``` ### Response #### Success Response (200) - **exists** (boolean) - True if the file exists, false otherwise. #### Response Example ```json { "exists": true } ``` ``` -------------------------------- ### currentDirectory Source: https://context7.com/fischerscode/ftpconnect/llms.txt Retrieves the absolute path of the current working directory on the FTP server. ```APIDOC ## currentDirectory ### Description Returns the absolute path of the current working directory on the FTP server. ### Method GET (or similar, depending on FTP command implementation) ### Endpoint Not applicable (method call on an object) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```dart String currentDir = await ftpConnect.currentDirectory(); ``` ### Response #### Success Response (200) - **currentDir** (string) - The absolute path of the current working directory. #### Response Example ```json { "currentDir": "/home/user/uploads" } ``` ``` -------------------------------- ### Check if File Exists on FTP Server Source: https://context7.com/fischerscode/ftpconnect/llms.txt Verifies the existence of a file on the FTP server. Useful for conditional operations like downloads. ```dart import 'package:ftpconnect/ftpconnect.dart'; void main() async { FTPConnect ftpConnect = FTPConnect('ftp.example.com', user: 'user', pass: 'pass'); try { await ftpConnect.connect(); bool exists = await ftpConnect.existFile('important_file.txt'); if (exists) { print('File exists, proceeding with download...'); } else { print('File not found on server'); } await ftpConnect.disconnect(); } catch (e) { print('Error: ${e.toString()}'); } } ``` -------------------------------- ### deleteEmptyDirectory Source: https://context7.com/fischerscode/ftpconnect/llms.txt Deletes an empty directory from the FTP server. The directory must be empty for this operation to succeed. ```APIDOC ## deleteEmptyDirectory ### Description Deletes an empty directory from the FTP server. The directory must be empty for this operation to succeed. ### Method DELETE (or similar, depending on FTP command implementation) ### Endpoint Not applicable (method call on an object) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```dart await ftpConnect.deleteEmptyDirectory('old_empty_folder'); ``` ### Response #### Success Response (200) - **deleted** (boolean) - True if the directory was deleted successfully, false otherwise. #### Response Example ```json { "deleted": true } ``` ``` -------------------------------- ### changeDirectory Source: https://context7.com/fischerscode/ftpconnect/llms.txt Changes the current working directory on the FTP server. Supports navigating to subdirectories, parent directories ('..'), and the root ('/'). ```APIDOC ## changeDirectory ### Description Changes the current working directory on the FTP server. Use '..' to navigate to the parent directory. ### Method POST (or similar, depending on FTP command implementation) ### Endpoint Not applicable (method call on an object) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```dart await ftpConnect.changeDirectory('uploads'); await ftpConnect.changeDirectory('..'); await ftpConnect.changeDirectory('/'); ``` ### Response #### Success Response (200) - **changed** (boolean) - True if the directory was changed successfully, false otherwise. #### Response Example ```json { "changed": true } ``` ``` -------------------------------- ### deleteDirectory Source: https://context7.com/fischerscode/ftpconnect/llms.txt Recursively deletes a directory and all its contents (files and subdirectories) from the FTP server. ```APIDOC ## deleteDirectory ### Description Recursively deletes a directory and all its contents (files and subdirectories) from the FTP server. ### Method DELETE (or similar, depending on FTP command implementation) ### Endpoint Not applicable (method call on an object) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```dart await ftpConnect.deleteDirectory('old_folder_with_contents', cmd: DIR_LIST_COMMAND.MLSD); ``` ### Response #### Success Response (200) - **deleted** (boolean) - True if the directory and its contents were deleted successfully, false otherwise. #### Response Example ```json { "deleted": true } ``` ``` -------------------------------- ### Download File with Retry Mechanism Source: https://context7.com/fischerscode/ftpconnect/llms.txt Downloads a remote file with an automatic retry mechanism to handle connection failures. Specify the number of retry attempts. ```dart import 'dart:io'; import 'package:ftpconnect/ftpconnect.dart'; void main() async { FTPConnect ftpConnect = FTPConnect('ftp.example.com', user: 'user', pass: 'pass'); try { await ftpConnect.connect(); String remoteFile = 'large_file.zip'; File localFile = File('/path/to/downloads/large_file.zip'); // Download with 2 retry attempts bool success = await ftpConnect.downloadFileWithRetry( remoteFile, localFile, pRetryCount: 2 ); if (success) { print('File downloaded to: ${localFile.path}'); } else { print('Download failed after retries'); } await ftpConnect.disconnect(); } catch (e) { print('Error: ${e.toString()}'); } } ``` -------------------------------- ### Rename File or Directory on FTP Server Source: https://context7.com/fischerscode/ftpconnect/llms.txt Use this to rename files, directories, or move files to different directories on the FTP server. Ensure you are connected before calling. ```dart import 'package:ftpconnect/ftpconnect.dart'; void main() async { FTPConnect ftpConnect = FTPConnect('ftp.example.com', user: 'user', pass: 'pass'); try { await ftpConnect.connect(); // Rename a file bool renamed = await ftpConnect.rename('old_name.txt', 'new_name.txt'); print('File renamed: $renamed'); // Rename a directory renamed = await ftpConnect.rename('old_folder', 'new_folder'); print('Directory renamed: $renamed'); // Move file to different directory (rename with path) renamed = await ftpConnect.rename('file.txt', 'archive/file.txt'); print('File moved: $renamed'); await ftpConnect.disconnect(); } catch (e) { print('Error: ${e.toString()}'); } } ``` -------------------------------- ### Recursively Delete Directory on FTP Server Source: https://context7.com/fischerscode/ftpconnect/llms.txt Use `deleteDirectory` to recursively remove a directory and all its contents, including files and subdirectories. Specify `DIR_LIST_COMMAND.MLSD` for efficient deletion. ```dart import 'package:ftpconnect/ftpconnect.dart'; void main() async { FTPConnect ftpConnect = FTPConnect('ftp.example.com', user: 'user', pass: 'pass'); try { await ftpConnect.connect(); // Delete directory with all contents recursively bool deleted = await ftpConnect.deleteDirectory( 'old_folder_with_contents', cmd: DIR_LIST_COMMAND.MLSD ); print('Directory and contents deleted: $deleted'); await ftpConnect.disconnect(); } catch (e) { print('Error: ${e.toString()}'); } } ``` -------------------------------- ### Upload Files with Retry Mechanism Source: https://context7.com/fischerscode/ftpconnect/llms.txt Perform file uploads with an automatic retry count, useful for maintaining stability on unreliable network connections. ```dart import 'dart:io'; import 'package:ftpconnect/ftpconnect.dart'; void main() async { FTPConnect ftpConnect = FTPConnect('ftp.example.com', user: 'user', pass: 'pass'); try { File fileToUpload = File('/path/to/upload.txt'); await ftpConnect.connect(); // Attempt upload with 3 retries on failure bool success = await ftpConnect.uploadFileWithRetry( fileToUpload, pRemoteName: 'uploaded_file.txt', pRetryCount: 3 ); print('Upload with retry: ${success ? "SUCCESSFUL" : "FAILED"}'); await ftpConnect.disconnect(); } catch (e) { print('Error: ${e.toString()}'); } } ``` -------------------------------- ### Delete Empty Directory on FTP Server Source: https://context7.com/fischerscode/ftpconnect/llms.txt The `deleteEmptyDirectory` function removes an empty directory from the FTP server. This operation will fail if the directory contains any files or subdirectories. ```dart import 'package:ftpconnect/ftpconnect.dart'; void main() async { FTPConnect ftpConnect = FTPConnect('ftp.example.com', user: 'user', pass: 'pass'); try { await ftpConnect.connect(); bool deleted = await ftpConnect.deleteEmptyDirectory('old_empty_folder'); print('Directory deleted: $deleted'); await ftpConnect.disconnect(); } catch (e) { print('Error: ${e.toString()}'); } } ``` -------------------------------- ### Rename File or Directory Source: https://context7.com/fischerscode/ftpconnect/llms.txt Renames a file or directory on the FTP server. This can also be used to move files to different directories. ```APIDOC ## RENAME ### Description Renames a file or directory on the FTP server. This can also be used to move files to different directories. ### Method POST (or equivalent FTP command) ### Endpoint Not applicable (method on an existing connection) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```dart await ftpConnect.rename('old_name.txt', 'new_name.txt'); await ftpConnect.rename('file.txt', 'archive/file.txt'); ``` ### Response #### Success Response (200) - **renamed** (boolean) - True if the rename operation was successful, false otherwise. #### Response Example ```json { "renamed": true } ``` ``` -------------------------------- ### Delete File Source: https://context7.com/fischerscode/ftpconnect/llms.txt Deletes a specified file from the FTP server. ```APIDOC ## DELETE FILE ### Description Deletes a specified file from the FTP server. ### Method POST (or equivalent FTP command) ### Endpoint Not applicable (method on an existing connection) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```dart await ftpConnect.deleteFile('old_file.txt'); ``` ### Response #### Success Response (200) - **deleted** (boolean) - True if the file was successfully deleted, false otherwise. #### Response Example ```json { "deleted": true } ``` ``` -------------------------------- ### Delete File from FTP Server Source: https://context7.com/fischerscode/ftpconnect/llms.txt Deletes a specified file from the FTP server. Requires an active connection. ```dart import 'package:ftpconnect/ftpconnect.dart'; void main() async { FTPConnect ftpConnect = FTPConnect('ftp.example.com', user: 'user', pass: 'pass'); try { await ftpConnect.connect(); bool deleted = await ftpConnect.deleteFile('old_file.txt'); print('File deleted: $deleted'); // Output: File deleted: true await ftpConnect.disconnect(); } catch (e) { print('Error: ${e.toString()}'); } } ``` -------------------------------- ### disconnect Source: https://context7.com/fischerscode/ftpconnect/llms.txt Closes the active FTP connection. ```APIDOC ## disconnect ### Description Closes the connection to the FTP server. Should be called after completing all FTP operations to properly release resources. ### Response - **bool** - Returns true if the disconnection is successful. ``` -------------------------------- ### Disconnect from FTP Server Source: https://context7.com/fischerscode/ftpconnect/llms.txt Close the active FTP connection to release system resources after operations are complete. ```dart import 'dart:io'; import 'package:ftpconnect/ftpconnect.dart'; void main() async { FTPConnect ftpConnect = FTPConnect('ftp.example.com', user: 'user', pass: 'pass'); await ftpConnect.connect(); // ... perform FTP operations ... bool disconnected = await ftpConnect.disconnect(); print('Disconnected: $disconnected'); // Output: Disconnected: true } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.