2017-06-15 57 views
1

是有可能得到定制的存储元数据在云计算功能的火力地堡? 例如在Android的代码:获取元数据存储在云计算功能的火力地堡

StorageMetadata metadata = new StorageMetadata.Builder().setContentType("image/jpg") 
         .setCustomMetadata("latitude",String.valueOf(image.latitude)) 
         .setCustomMetadata("longitude",String.valueOf(image.longitude)) 
         .setCustomMetadata("deviceID",image.deviceID) 
         .setCustomMetadata("userID",image.userID) 
         .setCustomMetadata("deviceFilePath",image.filename) 
         .setCustomMetadata("timestamp",String.valueOf(image.timestamp)) 
         .setCustomMetadata("caption",image.caption) 
         .setCustomMetadata("location",image.location) 
         .setCustomMetadata("imageID",key) 
         .build(); 

我想在云计算功能检索到的自定义元数据值

回答

0

当然,你可以使用Google Cloud Storage Node SDK在您的存储桶文件的工作。用它来获得一个File对象指向感兴趣的文件。然后调用它的getMetadata()方法来获取元数据。

+0

你有什么例子,如何做到这一点? –

+0

没有派上用场,但API文档是非常简单的,所以你应该能够与它进行实验。 –

0

可以在云功能获取自定义元数据如下图所示使用event.data.metadata。

如果你想看到完整的例子,这里是链接http://www.zoftino.com/android-firebase-cloud-functions-cloud-storage-trigger-example

exports.metadata = functions.storage.object().onChange(event => { 

    //metada 
    const fileInfo = event.data; 

//custom metadata 
    const customMetadata = fileInfo.metadata; 

    //get each custom metadata value using its key like.. 
    const customMetadataDeviceID = customMetadata['deviceID']; 

.......