I’m trying to upload video that user chooses (through uiimagepickercontroller), to Firebase storage, but I’m getting this strange error within my localizedDescription
an unknown error occurred, please check the server response
Here’s my code:
func uploadVideo(videoURL: URL)
{
let storage = Storage.storage()
let storageRef = storage.reference()
let videoRef = storageRef.child("rPosts/(uid!)/(fileID)")
let metadata = StorageMetadata()
metadata.contentType = "video/quicktime"
videoRef.putFile(from: videoURL, metadata: metadata)
{ (metaData, error) in
guard error == nil else
{
self.errorLabel.text = error!.localizedDescription
//error happens here :(
return
}
print("works")
}
}
Here is where it’s used:
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any])
{
if let url = info[UIImagePickerController.InfoKey.mediaURL] as? URL
{
uploadVideo(videoURL: url)
uploadedYet = true
}
videoPickerController.dismiss(animated: true, completion: nil)
}
2
Answers
Use Firebase’s
putData:
method to Upload your Data,Try it this way:
Check your Firebase Storage settings, I changed settings with ;
And fixed it .