ContentType 和元数据在存储写入规则中授予权限被拒绝

时间:2021-06-30 16:11:33

标签: firebase unity3d firebase-storage

我似乎无法让 MetadataChange 与存储规则一起工作。

我使用 Unity。

我设置的 MetadataChange 类似于文档:

var newMetadata = new MetadataChange
        {
            CustomMetadata = new Dictionary<string, string> 
            {        
                {"check", "1"}      
            },

            ContentType = "image/jpg"
        };

        await imageRef.PutBytesAsync(bytes, newMetadata).ContinueWith((Task<StorageMetadata> task) => {

然后当我尝试时:

allow write: if request.resource.contentType.matches('image/jpg');

allow write: if request.resource.metadata['check'] == '1';

这些都不起作用。我收到权限被拒绝错误。

我能够使许多其他规则起作用,但从来没有这两个。

read: resource.contentType.matches('image/jpg')

似乎工作正常。

谢谢。

0 个答案:

没有答案