ios – flutter_downloader – Save the file with a reputation with particular characters

From the bundle’s conduct, there isn’t any direct strategy to change this conduct within the bundle itself.
One potential workaround is to post-process the downloaded file and rename it to the specified filename. This may be executed utilizing the dart:io
bundle’s File class, particularly the rename methodology.
So you’ll want to obtain it, get the trail and rename it
Here is an instance of how to do that:
import 'dart:io';
// Assume that is your downloaded file
File downloadedFile = File('path_to_downloaded_file/abc____.textual content');
// That is your required filename
String desiredFileName = fileUrl.break up("/").final //i.e "abc ông @.textual content";
// Rename the file
downloadedFile.renameSync('path_to_downloaded_file/$desiredFileName');
On this code, renameSync modifications the identify of the file on the given path, which ought to replicate your required filename with areas and particular characters.
Please notice that you’ll want to deal with the case the place a file with the identical identify already exists within the listing. The renameSync methodology will throw an exception in such a case. If you wish to overwrite present recordsdata, you should use renameSync together with deleteSync:
if (File('path_to_downloaded_file/$desiredFileName').existsSync()) {
File('path_to_downloaded_file/$desiredFileName').deleteSync();
}
downloadedFile.renameSync('path_to_downloaded_file/$desiredFileName');
This code checks if a file with the specified identify already exists, and if it does, deletes it earlier than renaming the downloaded file.
Credit: www.ismmailgsm.com