I have the in-memory bytes of a "blob", but the API that I want to process this "blob" with only accepts dart:io File objects.
Is there a way to create a "fake" dart:io File , simply wrapping my in-memory bytes, so that I can pass this "fake" File to my API?
Assume that a file system doesn't exist, and assume that I can't write the in-memory bytes to a "real" file.
Thanks!
Write to a file To write a string to a file, use the writeAsString method: import 'dart:io'; void main() async { final filename = 'file. txt'; var file = await File(filename). writeAsString('some content'); // Do something with the file. }
You can create a memory-file using MemoryFileSystem
from the package file:
Example:
File file = MemoryFileSystem().file('test.dart')
..writeAsBytesSync(blobBytes);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With