React-native-firebase: storage putFile() ignores custom metadata

Created on 6 Feb 2018  路  3Comments  路  Source: invertase/react-native-firebase

Issue

storage putFile() ignores custom metadata. Standard metadata such as contentType works.

import firebase from 'react-native-firebase';

firebase.storage()
      .ref().child(storageName)
      .putFile(data.path, { contentType: 'video', uid: this.props.user.uid, "okok": "okok"})

Expected: metadata "contentType", "uid", and "okok" listed in firebase storage ui for the uploaded file

Actual: contentType is correctly set, but no other custom metadata is present

Environment

Android

  1. Application Target Platform: macOS Sierra

  2. Development Operating System: react-native run-android, Nexus P6 API 26.

  3. Build Tools: ?

  4. React Native version: ^0.52.1

  5. RNFirebase Version: ^3.2.2

  6. Firebase Module: storage

Storage Waiting for User Response

Most helpful comment

@jonaseck2 Can you try putting the custom data into a customMetadata object:

firebase.storage()
      .ref().child(storageName)
      .putFile(data.path, { contentType: 'video', customMetadata: { uid: this.props.user.uid, "okok": "okok"}})

Storage is another area that we need to take a look at after FCM as it's not had much attention, but I'm fairly sure this may be an undocumented feature

All 3 comments

@jonaseck2 Can you try putting the custom data into a customMetadata object:

firebase.storage()
      .ref().child(storageName)
      .putFile(data.path, { contentType: 'video', customMetadata: { uid: this.props.user.uid, "okok": "okok"}})

Storage is another area that we need to take a look at after FCM as it's not had much attention, but I'm fairly sure this may be an undocumented feature

Closing due to lack of response - Please let us know if this doesn't work.

Yeah, it works. Good to know is the key is omitted if the value is null

Was this page helpful?
0 / 5 - 0 ratings