Сохранить аудио на Firebase с Kotlin

Привет, я беру аудиозапись в своем проекте, но я хочу сохранить эти записи в базе данных firebase с именем пользователя и именем темы, как я могу это сделать?

Мой код записывает звуковую запись продолжительностью 60 секунд, после чего прекращается запись.

Вот мои коды сохранения записи.

class MainActivity : AppCompatActivity(), MediaPlayer.OnCompletionListener { lateinit var recorder: MediaRecorder lateinit var player: MediaPlayer lateinit var file: File lateinit var button1: Button lateinit var button2: Button lateinit var button3: Button lateinit var saveButton: Button lateinit var tv1: TextView lateinit var timeText : TextView lateinit var topicText: EditText var handler: Handler = Handler() var runnbale: Runnable = Runnable { } var cihan: CountDownTimer? = null val fbsignup = FirebaseAuth.getInstance() lateinit var mDatabase:DatabaseReference var user = FirebaseAuth.getInstance().currentUser private var mFileName = null override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) val nameText = findViewById<View>(R.id.nameText) as TextView var uid = user!!.uid mDatabase =FirebaseDatabase.getInstance().getReference("Nicks") mDatabase.child(uid).child("Nick").addValueEventListener(object : ValueEventListener{ override fun onCancelled(p0: DatabaseError?) { } override fun onDataChange(snapshot: DataSnapshot) { nameText.text ="Welcome " + snapshot.value.toString() } }) val intent = intent tv1 = findViewById (R.id.tv1) as TextView button1 = findViewById (R.id.button1) as Button button2 = findViewById (R.id.button2) as Button button3 = findViewById (R.id.button3) as Button topicText =findViewById(R.id.topicText) saveButton=findViewById(R.id.saveButton) timeText = findViewById(R.id.timeText) as TextView var button2clk: View.OnClickListener = View.OnClickListener{ cihan?.cancel() recorder.stop () recorder.release () player = MediaPlayer () player.setOnCompletionListener (this) try { player.setDataSource(file.absolutePath) } catch (e: IOException) { } try { player.prepare () } catch (e: IOException) { } button1.setEnabled (true) button2.setEnabled (false) button3.setEnabled (true) tv1.text = "Ready to play" timeText.text ="Done!" } button1.setOnClickListener { if (topicText.text.toString().length == 0){ button1.isClickable=false Toast.makeText(this, "The topic must be Entered!!",Toast.LENGTH_LONG).show() } recorder = MediaRecorder() recorder.setAudioSource(MediaRecorder.AudioSource.MIC) recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4) recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB) val path = File (Environment.getExternalStorageDirectory().getPath()) try { file = File.createTempFile ("temporary", ".mp3", path) } catch (e: IOException) { } recorder.setOutputFile(file.absolutePath) try { recorder.prepare () } catch (e: IOException) { } recorder.start() tv1.text = "Recording" button1.setEnabled(false) button2.setEnabled(true) button3.setEnabled(false) cihan = object : CountDownTimer(60000,1000) { override fun onFinish(){ timeText.text = "Time's Finish!" button2clk.onClick(button2) } override fun onTick(p0: Long) { timeText.text = "Time: "+ p0/1000 +" Sec" } }.start() } button2.setOnClickListener(button2clk) button3.setOnClickListener { player.start(); button1.setEnabled (false); button2.setEnabled (false); button3.setEnabled (false); tv1.setText ("Playing"); } } override fun onCompletion (mp: MediaPlayer) { button1.setEnabled (true) button2.setEnabled (false) button3.setEnabled (true) tv1.setText ("Ready") } override fun onCreateOptionsMenu(menu: Menu?): Boolean { menuInflater.inflate(R.menu.menu,menu) return super.onCreateOptionsMenu(menu) } 

Эта часть позволяет вам выписать приложение.

 override fun onOptionsItemSelected(item: MenuItem?): Boolean { if (item!!.itemId == R.id.signOut) fbsignup.signOut() startActivity(Intent(this,UserLogin::class.java)) Toast.makeText(this,"Logged Out!",Toast.LENGTH_LONG).show() return super.onOptionsItemSelected(item) } } 

Спасибо за все.