function uploadFileWithProgress(
  dispatch,
  firebase,
  { path, file, filename, meta, fileMetadata }
) {
  const uploadEvent = firebase
    .storage()
    .ref(`${path}/${filename}`)
    .put(file, fileMetadata)

  const unListen = uploadEvent.on(firebase.storage.TaskEvent.STATE_CHANGED, {
    next: (snapshot) => {
      dispatch({
        type: FILE_UPLOAD_PROGRESS,
        meta,
        payload: {
          snapshot,
          percent: Math.floor(
            (snapshot.bytesTransferred / snapshot.totalBytes) * 100
          )
        }
      })
    },
    error: (err) => {
      dispatch({ type: FILE_UPLOAD_ERROR, meta, payload: err })
      unListen()
    },
    complete: () => {
      unListen()
    }
  })
  return uploadEvent
}
Upload a file with actions fired for progress, success, and errors
@param {Function} dispatch - Action dispatch function
@param {object} firebase - Internal firebase object
@param {object} opts - File data object
@param {object} opts.path - Location within Firebase Stroage at which to upload file.
@param {Blob} opts.file - File to upload
@param {object} opts.fileMetadata - Metadata to pass along to storageRef.put call
@param {object} opts.meta - Meta object
@returns {Promise} Promise which resolves after file upload
@private