Flutter_cached_network_image: FileSystemException (OS Error: Is a directory, errno = 21)

Created on 1 Oct 2019  ยท  12Comments  ยท  Source: Baseflow/flutter_cached_network_image

I was starting my app in flight mode (no internet connection) to check if cached network images would reload automatically when I turned internet access back on. The urls are stored in firestore, so not sure if the urls were cached or not.

(Firestore does automatically update data when internet is turned back on, but cached network images are only displayed when their widgets are reloaded)

When turning internet back on this exception happened:

I/flutter (10496): โ•โ•โ•ก EXCEPTION CAUGHT BY IMAGE RESOURCE SERVICE โ•žโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
I/flutter (10496): The following FileSystemException was thrown resolving an image codec:
I/flutter (10496): Cannot open file, path = '/data/user/0/se.myapp/cache/libCachedImageData' (OS Error: Is
I/flutter (10496): a directory, errno = 21)
I/flutter (10496): 
I/flutter (10496): When the exception was thrown, this was the stack:
I/flutter (10496): #0      _File.open.<anonymous closure> (dart:io/file_impl.dart:364:9)
I/flutter (10496): (elided 13 frames from package dart:async)
I/flutter (10496): ...
I/flutter (10496): 
I/flutter (10496): Path: /data/user/0/se.myapp/cache/libCachedImageData
I/flutter (10496): โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
bug

Most helpful comment

I also get the expeption. But when I restart the app it's working. The issue only appears sometimes.

When it's happen I get:

โ•โ•โ•โ•โ•โ•โ•โ• Exception caught by image resource service โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
The following FileSystemException was thrown resolving an image codec:
Cannot open file, path = '/data/user/0/devnik.dev_releases/cache/libCachedImageData/31e512d0-6c49-11ea-dc7d-c3a13eec1fc5.octet-stream' (OS Error: No such file or directory, errno = 2)

When the exception was thrown, this was the stack: 
#0      _File.open.<anonymous closure> (dart:io/file_impl.dart:366:9)
(elided 13 frames from package dart:async)
Path: /data/user/0/devnik.dev_releases/cache/libCachedImageData/31e512d0-6c49-11ea-dc7d-c3a13eec1fc5.octet-stream
โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

Why it tries to open a .octet-stream file? Its a normal image.

Someone knows a workaround to refresh the cached images if it fails ?

I also use cached_network_image: ^2.0.0

If I restart the app and the app is able to read the cached file I get (it can read the .png file instead of .octet-stream):

grafik
Debugged in flutter\flutter\packages\flutter\lib\src\painting\image_provider.dart (line: 649)

All 12 comments

I'm also having this issue. This is the most common error in my Firebase Crashlytics service.

Do you have any idea why or when this happens? The path in the exception is the folder where the files should be put in.

If I remember correctly the issue might happen after upgrading
cached_network_image from an old version

Den tis 5 nov. 2019 07:47Rene Floor notifications@github.com skrev:

Do you have any idea why or when this happens? The path in the exception
is the folder where the files should be put in.

โ€”
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/renefloor/flutter_cached_network_image/issues/252?email_source=notifications&email_token=AAHZACTSZEZAQQVGBZRYGILQSEJIVA5CNFSM4I4FRZWKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEDBYYQI#issuecomment-549686337,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAHZACV4UVQ47MKHFAMNSY3QSEJIVANCNFSM4I4FRZWA
.

Even I am facing this issue a lot with the new plugin update.

Same thing on version 2.0.0

Same error with:
cached_network_image: ^2.0.0

If you have a reproducable example that would be great, because I'm not sure where this is going wrong.

I also get the expeption. But when I restart the app it's working. The issue only appears sometimes.

When it's happen I get:

โ•โ•โ•โ•โ•โ•โ•โ• Exception caught by image resource service โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
The following FileSystemException was thrown resolving an image codec:
Cannot open file, path = '/data/user/0/devnik.dev_releases/cache/libCachedImageData/31e512d0-6c49-11ea-dc7d-c3a13eec1fc5.octet-stream' (OS Error: No such file or directory, errno = 2)

When the exception was thrown, this was the stack: 
#0      _File.open.<anonymous closure> (dart:io/file_impl.dart:366:9)
(elided 13 frames from package dart:async)
Path: /data/user/0/devnik.dev_releases/cache/libCachedImageData/31e512d0-6c49-11ea-dc7d-c3a13eec1fc5.octet-stream
โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

Why it tries to open a .octet-stream file? Its a normal image.

Someone knows a workaround to refresh the cached images if it fails ?

I also use cached_network_image: ^2.0.0

If I restart the app and the app is able to read the cached file I get (it can read the .png file instead of .octet-stream):

grafik
Debugged in flutter\flutter\packages\flutter\lib\src\painting\image_provider.dart (line: 649)

i get the same behavior as @devonik , any updates on this ?

i get the same behavior as @devonik , any updates on this ?

No solution right now. I will try to use another library cache_image. It comes with firebase support and reloading if failed

Same issue here, but I trying to download a PDF file..

I also get the expeption. But when I restart the app it's working. The issue only appears sometimes.

When it's happen I get:

โ•โ•โ•โ•โ•โ•โ•โ• Exception caught by image resource service โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
The following FileSystemException was thrown resolving an image codec:
Cannot open file, path = '/data/user/0/devnik.dev_releases/cache/libCachedImageData/31e512d0-6c49-11ea-dc7d-c3a13eec1fc5.octet-stream' (OS Error: No such file or directory, errno = 2)

When the exception was thrown, this was the stack: 
#0      _File.open.<anonymous closure> (dart:io/file_impl.dart:366:9)
(elided 13 frames from package dart:async)
Path: /data/user/0/devnik.dev_releases/cache/libCachedImageData/31e512d0-6c49-11ea-dc7d-c3a13eec1fc5.octet-stream
โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

Why it tries to open a .octet-stream file? Its a normal image.

Someone knows a workaround to refresh the cached images if it fails ?

I also use cached_network_image: ^2.0.0

If I restart the app and the app is able to read the cached file I get (it can read the .png file instead of .octet-stream):

grafik
Debugged in flutter\flutter\packages\flutter\lib\src\painting\image_provider.dart (line: 649)

i have same issue
did you Solve it?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

love-bkpp picture love-bkpp  ยท  5Comments

anass-naoushi picture anass-naoushi  ยท  5Comments

gunhansancar picture gunhansancar  ยท  3Comments

gjrjf picture gjrjf  ยท  4Comments

digitaldangal picture digitaldangal  ยท  5Comments