Skip to content

SFTP download is slow #124

@Sravdar

Description

@Sravdar

Hello. I do host sftp server on same computer where i do this test. Using windows machine, "sftpgo" for the sftp server.

When i try to download files via following code i get around max 1MB/s speed. When using filezilla i can get about 200 MB/s. Is there anyway to write this code in more optimized way? I am open for ideas here.

var remoteFileConnection = await sftp.open(file.filename, mode: SftpFileOpenMode.read);
var writeFile = File(p.join(pathSftpCache, file.filename));
if(writeFile.existsSync()) {
  writeFile.deleteSync();
}
writeFile.createSync(recursive: true);
var writeStream = writeFile.openWrite();
var readStream = remoteFileConnection.read();

await for (final chunk in readStream) {
  copiedBytes += chunk.length;
  writeStream.add(chunk);
  onProgress(copiedBytes / totalDownloadSize);
}

dartssh2: ^2.11.0

[√] Flutter (Channel stable, 3.27.4, on Microsoft Windows [Version 10.0.26100.3476], locale tr-TR)
    • Flutter version 3.27.4 on channel stable at C:\Flutter\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision d8a9f9a52e (7 weeks ago), 2025-01-31 16:07:18 -0500
    • Engine revision 82bd5b7209
    • Dart version 3.6.2
    • DevTools version 2.40.3

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at C:\Users\username\AppData\Local\Android\sdk
    • Platform android-35, build-tools 35.0.0
    • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.11+0--11852314)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.12.4)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.12.35707.178
    • Windows 10 SDK version 10.0.22621.0

[√] Android Studio (version 2024.1)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.11+0--11852314)

[√] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.26100.3476]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 134.0.6998.118
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 132.0.2957.140

[√] Network resources
    • All expected network resources are available.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions