Record audio in web and get the data #432
Unanswered
ramakrishna-veli
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi Everyone I am using Record library for record audio messages and sent in my chat app using flutter, In mobile it's working completely fine because we have local storage but in web I am able to record the audio and send it in chat I am facing issues because it is giving some blob url as output path I am using getstream.io library for my chat application, this is the model of how to send audio message from web in Stream chat /// The class that contains the information about an attachment file
@JsonSerializable()
class AttachmentFile {
/// Creates a new [AttachmentFile] instance.
AttachmentFile({
required this.size,
this.path,
String? name,
this.bytes,
}) : assert(
path != null || bytes != null,
'Either path or bytes should be != null',
),
assert(
!CurrentPlatform.isWeb || bytes != null,
'File by path is not supported in web, Please provide bytes',
),
assert(
name?.contains('.') ?? true,
'Invalid file name, should also contain file extension',
),
_name = name;
/// Create a new instance from a json
factory AttachmentFile.fromJson(Map<String, dynamic> json) =>
_$AttachmentFileFromJson(json);
/// The absolute path for a cached copy of this file. It can be used to
/// create a file instance with a descriptor for the given path.
///
/// final File myFile = File(platformFile.path); ///
final String? path;
final String? _name;
/// File name including its extension.
String? get name =>
_name ?? path?.split(CurrentPlatform.isWindows ? r'' : '/').last;
/// Byte data for this file. Particularly useful if you want to manipulate
/// its data or easily upload to somewhere else.
@jsonkey(includeToJson: false, includeFromJson: false)
final Uint8List? bytes;
/// The file size in bytes.
final int? size;
/// File extension for this file.
String? get extension => name?.split('.').last;
/// The mime type of this file.
MediaType? get mediaType => name?.mediaType;
/// Serialize to json
Map<String, dynamic> toJson() => _$AttachmentFileToJson(this);
/// Converts this into a [MultipartFile]
Future toMultipartFile() async {
MultipartFile multiPartFile;
}
/// Creates a copy of this [AttachmentFile] but with the given fields
/// replaced with the new values.
AttachmentFile copyWith({
String? path,
String? name,
Uint8List? bytes,
int? size,
}) {
return AttachmentFile(
path: path ?? this.path,
name: name ?? this.name,
bytes: bytes ?? this.bytes,
size: size ?? this.size,
);
}
} please help
Beta Was this translation helpful? Give feedback.
All reactions