Firebase 使用storagage().bucket().file(文件名).save(文件名)包含自定义元数据
我正在尝试使用云函数上载字符串。我能够成功地将字符串作为CSV上传,但我找不到包含自定义元数据的方法 我尝试了人们在网上提出的所有建议,但似乎都没有达到预期的效果。以下是我目前的尝试:Firebase 使用storagage().bucket().file(文件名).save(文件名)包含自定义元数据,firebase,google-cloud-platform,google-cloud-functions,google-cloud-storage,firebase-storage,Firebase,Google Cloud Platform,Google Cloud Functions,Google Cloud Storage,Firebase Storage,我正在尝试使用云函数上载字符串。我能够成功地将字符串作为CSV上传,但我找不到包含自定义元数据的方法 我尝试了人们在网上提出的所有建议,但似乎都没有达到预期的效果。以下是我目前的尝试: const file = admin.storage().bucket().file(csvName); return file.save(body, { gzip: true, contentType: 'text/csv',
const file = admin.storage().bucket().file(csvName);
return file.save(body, {
gzip: true,
contentType: 'text/csv',
//Trying to insert this metadata.
metadata: {
campaignId: doc.data().campaignId,
typeOfUpload: 'contacts'
}
})
除了我需要的自定义元数据之外,其他一切都按预期工作。非常感谢您的帮助。这是如何做到的:
const file = admin.storage().bucket().file(csvName);
return file.save(body, {
metadata: {
contentType: 'text/csv',
gzip: true,
metadata: {
campaignId: doc.data().campaignId,
typeOfUpload: 'contacts'
}
}
})