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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With