[ad_1]
i attempt to choose audio file on ios system, and when add file with the DIO i acquired no such file or director. I choose file with then file_picker. After that i attempted to repeat file (if present system is ios) to getApplicationDocumentsDirectory, however acquired this message on copy proccess
`
void selectAudio() async {
ultimate FilePickerResult? consequence = await FilePicker.platform.pickFiles(
kind: FileType.audio,
allowMultiple: true,
);
if (consequence == null) return;
if (fileList.size + consequence.recordsdata.size > 6) {
Get.showErrorMessage(
'txt_oops'.tr,
'txt_max_amount_of_selected_files'.tr,
);
return;
}
for (PlatformFile file in consequence.recordsdata) {
fileList.add(
FileModel(null)..localfile = file.path,
);
}
}
Future<void> uploadFile(FileModel file, String mimeType) async {
File localFile = File(file.localfile!);
if (Platform.isIOS) {
String documentPath = (await getApplicationDocumentsDirectory()).path;
localFile = await localFile.copy(
'$documentPath/${basename(localFile.path)}',
);
}
………
Future<FileModel?> uploadFile({
required int profileId,
required File file,
void Perform(int present, int whole, int p.c)? onSendProgress,
}) {
return uploadFileToServer(
url: "profile/$profileId/file/",
onSendProgress: onSendProgress == null
? null
: (int present, int whole) {
int p.c = (present / whole * 100).toInt();
onSendProgress(present, whole, p.c);
},
formData: dio.FormData.fromMap({
"file": dio.MultipartFile.fromFileSync(
file.path,
filename: basename(file.path),
),
}),
);
}
`
[ad_2]
