I found that for uploading images using Android with a RequestBody, we can use MediaType.parse("image/jpeg").
However, what would be the parameter for an audio file ?
Thank you in advance for your answer.
I found that for uploading images using Android with a RequestBody, we can use MediaType.parse("image/jpeg").
However, what would be the parameter for an audio file ?
Thank you in advance for your answer.
You can get mime type of any file using this method:
public static String getMimeType(String url) {
String type = null;
String extension = MimeTypeMap.getFileExtensionFromUrl(url);
if (extension != null) {
type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
}
return type;
}
To get mime, call String mime = getMimeType(file.getAbsolutePath());
You can find list of all mimes here. And thus, mime for audio will be audio/mpeg
. But I will still recommend using getMimeTypeFromExtension
than hardcoding the value.
© 2022 - 2024 — McMap. All rights reserved.
MimeTypeMap.getFileExtensionFromUrl(url)
return nothing? – Azpurua