ios – Swift Firebase Storage Upload File From Local


I have an iOS app and I want to record my voice and upload it to firebase storage.

I create recording and can see it in the path like

file:///var/mobile/Containers/Data/Application/67D758EA-F98F-4AAB-A08D-41FA58D50446/Documents/rZSG.m4a

but when I give this path to firebase storage I have an error and it is like this

file:///var/mobile/Containers/Data/Application/67D758EA-F98F-4AAB-A08D-41FA58D50446/Documents/rZSG.m4a is not reachable. Ensure file URL is not a directory, symbolic link, or invalid url.

and here is the code I use to upload my voice recording

 // Local file you want to upload
let localFile = URL(string: filePath.description)!

// Create the file metadata
let metadata = StorageMetadata()
metadata.contentType = "video/m4a"
let uploadTask = storageRef.putFile(from: localFile, metadata: metadata)

How can I solve this issue?

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img