I get an audiofile from an API call, and I want to upload this file to my Firebase storage. The API calls returns:
{"success": true, "path": "https://developer.wontgivetheexactpath.mp3"}
When I click on the path, it automatically downloads the audio in my computer, but I don’t want that. I want it to go directly in my Storage. I tried this:
var audioFile = createAudio(
text: 'What is love? I don't know, but it doesn't matter.');
final ref = FirebaseStorage.instance.ref().child("audio/$audioFile");
ref.putFile(File(audioFile.toString()));
Note that createAudio()
is the function that returns the path resulting from the API call.
2
Answers
I found it out. I had to use the package
dio
to download the file on my computer first, then delete it. here is the code:Then I upload to Firebase Storage and delete it:
It really won’t forward it this way, for flutter it may vary according to the OS, you will need to use the packge path to standardize the OS paths, save in a temporary path and with this temporary path you will be able to change the folder and do the navigation you want, yes I know it’s annoying but it’s a solution that I already implemented years ago and it worked