fluttercommunity / fluttercommunity/flutter_downloader

The flutter_downloader plugin throws a java.io.IOException: File name too long error

Open
#997 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Kotlin
Stars
940
Forks
561
Avg merge
1h 18m
Merged PRs (30d)
1

Description

**Describe the bug**

The flutter_downloader plugin throws a java.io.IOException: File name too long error even when the filename length seems to be within limits. Additionally, a NullPointerException occurs during the download operation.

Directory path: /storage/emulated/0/Download/Thitsarparami/mp3/

Subdirectories: ဒေါက်တာနန္ဒမာလာဘိဝံသ/သုတဓမ္မဂဝေသီ-ba-1-မိလိန္ဒပဉှာ

Final filename: အပိုင်း-၄-မိလိန္ဒမင်းနှင့်ရှင်နာဂသေနတို့၏-ဗုဒ္ဓဝါဒရေးရာ-အခြေအတင်ပြောဆိုချက်များ-၁၂-၆-၁၆_1743004401641.mp3

/storage/emulated/0/Download/Thitsarparami/mp3/ဒေါက်တာနန္ဒမာလာဘိဝံသ/သုတဓမ္မဂဝေသီ-ba-1-မိလိန္ဒပဉှာ/အပိုင်း-၄-မိလိန္ဒမင်းနှင့်ရှင်နာဂသေနတို့၏-ဗုဒ္ဓဝါဒရေးရာ-အခြေအတင်ပြောဆိုချက်များ-၁၂-၆-၁၆_1743004401641.mp3

**To Reproduce**

To Reproduce

Steps to reproduce the behavior:

1. Use the flutter_downloader plugin to enqueue a download with a long filename and path.
2. Provide a valid URL for the file and a potentially long filename and directory path.
3. Observe the error when attempting to download the file.

**Expected behavior**

The file should be downloaded successfully with the provided filename and path, and no exceptions should be thrown due to filename length or null values.

**Screenshots**

**Device information:**

[✓] Flutter (Channel stable, 3.27.1, on macOS 15.3.2 24D81 darwin-x64, locale en-GB)
⡿^⣽Aungs-MacBook-Pro:thitsarparami_mobile aungmyooo$ flutter doctor -v
[✓] Flutter (Channel stable, 3.27.1, on macOS 15.3.2 24D81 darwin-x64, locale en-GB)
• Flutter version 3.27.1 on channel stable at /Users/aungmyooo/Development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 17025dd882 (3 months ago), 2024-12-17 03:23:09 +0900
• Engine revision cb4b5fff73
• Dart version 3.6.0
• DevTools version 2.40.2

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/aungmyooo/Library/Android/sdk
• Platform android-35, build-tools 34.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 21.0.5+-12932927-b750.29)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 16C5032a
• CocoaPods version 1.16.2

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.3)
• Android Studio at /Applications/Android Studio.app/Contents
• 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 21.0.5+-12932927-b750.29)

[✓] VS Code (version 1.98.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.106.0

[✓] Connected device (4 available)
• SM N975F (mobile) • RF8M82Y3K9A • android-arm64 • Android 12 (API 31)
• Aung Myo’s iPhone (mobile) • 00008120-0006612E0198A01E • ios • iOS 18.3.2 22D82
• macOS (desktop) • macos • darwin-x64 • macOS 15.3.2 24D81 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 134.0.6998.166

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

• No issues found!

**Additional context**

The issue seems to arise when the total file path (directory + filename) exceeds the system's maximum file path limit (usually around 255 bytes for the filename or up to 4096 bytes for the total path). The filename is correctly truncated to a safe length, but the path itself might be causing issues due to a combination of the long directory and filename. There’s also an occurrence of a NullPointerException in DownloadWorker.kt which seems unrelated to filename length but might indicate other issues in the plugin's logic for handling downloads.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.