Im trying to save an audio in the new Firebase Storage option, the audio is set as a .mp3 file and the uploaded to Firebase via this code : UploadTask uploadAudio = storageRef.putFile(audioUri); 
The problem is that the audio is stored as a video/mp4 file, and because of that the MediaPlayer does not reproduce it as an audio, how can I fix this?
You can explicitly specify metadata when you upload the file to Firebase. If you specify setContentType("audio/mpeg") it should map the file to an MP3 correctly.
Cloud Storage for Firebase allows you to quickly and easily upload files to a Cloud Storage bucket provided and managed by Firebase.
Moving comment to answer:
You can explicitly specify metadata when you upload the file to Firebase. If you specify setContentType("audio/mpeg") it should map the file to an MP3 correctly.
 class func uploadAudios(data : Data,completion :  @escaping (_ succus : String )->Void){
    var url = ""
    let storage = Storage.storage()
    // Create file metadata including the content type
    let metadata = StorageMetadata()
    metadata.contentType = "audio/mpeg"
    let uploadRef = storage.reference().child("audios/\(UUID().uuidString).mp3")
    uploadRef.putData(data, metadata: metadata) { metadata,
        error in
        if error == nil {
            print("successfully uploaded Audio")
            url = (metadata?.downloadURL()?.absoluteString)!
            print("AhmedRabie \(url)")
            completion(url)
        }
        else {
            print("UploadError \(String(describing: error))")
        }
        
    }
    
}
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