-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
uploading audio web by MultipartFile #278
Comments
@tas-unn The source use code in here : void startRecord(WidgetRef ref, bool state, int configValue) async {
if (!checkMultiModalStatus(ref, configValue)) return;
if (state) {
///
/// Important Note:
/// ```
/// final path = await recorder.stop();
/// ```
/// only support web, if you use it not in web, please get the actual file
/// pub lib:[https://pub.dev/packages/record]
///
final path = await recorder.stop();
if (path == null) {
ref.read(allowRecordProvider.notifier).updateStatus(false);
return;
}
final result = await http.get(Uri.parse(path));
ref.read(uploadFileProvider.notifier).uploadFileUrl(result.bodyBytes);
ref.read(allowRecordProvider.notifier).updateStatus(false);
return;
}
if (await recorder.hasPermission()) {
await recorder.start(const RecordConfig(encoder: AudioEncoder.wav),
path: "");
}
ref.read(allowRecordProvider.notifier).updateStatus(true);
} |
Again... @tas-unn, you can't stream wav as I answered before. |
Could you please sure the related link to @MannaYang guidance for us? |
Hello, my source code in here, you can use it as a reference : Project : ChatGPT-Flutter-Web
With audio recording :
With file provider :
With file repository :
With http request :
|
@MannaYang thanks for your help |
@AliKarimiENT Yes,try it now. |
I have not received a response, my issues are closed without answer (262,267)
Package version
5.0.3
Environment
Windows 10 Pro
Describe the bug
how to upload a file via dio that was recorded via web?
const encoder = AudioEncoder.wav;
const config = RecordConfig(encoder: encoder);
To Reproduce
Steps to reproduce the behavior:
took an example from the site
Changed the config
Added dio package
Commented out the write to the file, uncommented the write to the stream
in audio_recorder.dart file after line:
Amplitude? _amplitude;
i've added
List? mybytes;
and
// Record to stream
// await recordStream(_audioRecorder, config);
replaced by
mybytes= await recordStream(_audioRecorder, config);
and on _stop()
var formData=FormData();
formData.files.add(MapEntry(
"message_bytes",
MultipartFile.fromBytes(
mybytes!.cast())));
var response = await Dio().post(
"https://my.site/sendtest.php",
data: formData,
);
The sent data contains some bytes (the array is not empty), but the file is broken
Expected behavior
successful file upload
Additional context
The text was updated successfully, but these errors were encountered: