Custom metadata is not defined when uploading file

Client-side code:

firebase.storage().ref('products/' + Math.random().toString(36).substr(2, 9)).putFile(localImageURL, {
            contentType: 'image/jpeg',
            customMetadata: {
                merchantID: Auth.merchantID,
                category: 'knitwear'
            }
        }).on('state_changed', 
            (progress) => {
                dispatch({
                    type: 'UPLOAD_STATE_CHANGED',
                    data: progress
                })
            },
            (error) => {
                dispatch({
                    type: 'UPLOAD_FILE_ERROR',
                    data: error
                })
            },
            (uploadedFile) => {
                console.debug(uploadedFile);

                dispatch({
                    type: 'UPLOAD_FILE_COMPLETED',
                })
            })
    }

Then I want to catch this within a Cloud Function:

exports.generateThumbnail = functions.storage.object().onChange(event => {
  [...]
  console.log("Event:", event)
  const _merchant = event.data.customMetadata.merchantID;
  const _category = event.data.customMetadata.category;

Still, event.data.customMetadata is never defined.

  • Platform: iPhone 6 Simulator, iOS 10.3
  • macOS Sierra 10.12.5
  • XCode 8.3.2
  • react-native-cli: 2.0.1
  • react-native: 0.45.1
  • RNFirebase 2.0.4

Author: Fantashit

1 thought on “Custom metadata is not defined when uploading file

Comments are closed.

Custom metadata is not defined when uploading file

Client-side code:

firebase.storage().ref('products/' + Math.random().toString(36).substr(2, 9)).putFile(localImageURL, {
            contentType: 'image/jpeg',
            customMetadata: {
                merchantID: Auth.merchantID,
                category: 'knitwear'
            }
        }).on('state_changed', 
            (progress) => {
                dispatch({
                    type: 'UPLOAD_STATE_CHANGED',
                    data: progress
                })
            },
            (error) => {
                dispatch({
                    type: 'UPLOAD_FILE_ERROR',
                    data: error
                })
            },
            (uploadedFile) => {
                console.debug(uploadedFile);

                dispatch({
                    type: 'UPLOAD_FILE_COMPLETED',
                })
            })
    }

Then I want to catch this within a Cloud Function:

exports.generateThumbnail = functions.storage.object().onChange(event => {
  [...]
  console.log("Event:", event)
  const _merchant = event.data.customMetadata.merchantID;
  const _category = event.data.customMetadata.category;

Still, event.data.customMetadata is never defined.

  • Platform: iPhone 6 Simulator, iOS 10.3
  • macOS Sierra 10.12.5
  • XCode 8.3.2
  • react-native-cli: 2.0.1
  • react-native: 0.45.1
  • RNFirebase 2.0.4

Author: Fantashit

1 thought on “Custom metadata is not defined when uploading file

Comments are closed.