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.
Inside RNFirebaseStorage.m I can see this:
- (FIRStorageMetadata *)buildMetadataFromMap:(NSDictionary *)metadata {
NSMutableDictionary *result = [metadata mutableCopy];
result[@"metadata"] = metadata[@"customMetadata"];
[result removeObjectForKey:@"customMetadata"];
return [[FIRStorageMetadata alloc] initWithDictionary:result];
}
Is the customMetadata key being willingly removed for a specific purpose?
@DavideValdo that's a weird looking issue template you filled out there 馃憖
Next time please could you fill it out, we get a ton of issues and it's there to avoid wasting time going back and forth 馃檲 it also helps other looking for similar issues.
As for your issue, can you change your buildMetadataFromMap to the below and see if it works:
- (FIRStorageMetadata *)buildMetadataFromMap:(NSDictionary *)metadata {
return [[FIRStorageMetadata alloc] initWithDictionary:metadata];
}
Sorry about that, filled issue template for completeness. Trying your solution ASAP.
Sadly your solution didn't work
I'm going to try with Firebase from a webpage to rule out a Cloud Function issue, then edit this.
@DavideValdo I have a feeling it's our end, but if you could rule it out to make sure that'd be super helpful :)
Fixed in v3 (not yet released - keep an eye out for it).
Thanks for submitting the issue. 馃憤
Most helpful comment
Sorry about that, filled issue template for completeness. Trying your solution ASAP.