我已经阅读了许多帖子,可以帮助我解决这个问题。
这是此类错误的解决方案。(只需在androidmanifest.xml中插入一行代码)
android:requestLegacyExternalStorage=”true”
但在我的情况下,插入并没有起作用。 我现在正在使用React Native开发移动应用程序。 问题出现在我尝试将文件放入Firebase存储时。 当然,我已将那行代码插入到我的androidmanifest.xml文件中。
<application
android:name=”.MainApplication”
android:label=”@string/app_name”
android:icon=”@mipmap/ic_launcher”
android:roundIcon=”@mipmap/ic_launcher_round”
android:allowBackup=”false”
android:theme=”@style/AppTheme”
android:requestLegacyExternalStorage=”true”
>
以下是构建脚本
buildscript {
ext {
buildToolsVersion = “29.0.3”
minSdkVersion = 21
compileSdkVersion = 29
targetSdkVersion = 29
ndkVersion = “20.1.5948944”
playServicesVersion = “17.0.0”
androidMapsUtilsVersion = “2.2.3”
}
…
}
这是上传脚本
// uploads file
const pngRef = storage().ref(avatar/upload.png);
console.log(“pngRef”, pngRef);
await pngRef.putFile(fileUri);
const url = await storage()
.ref(avatar/upload.png)
.getDownloadURL();
console.log(“url”, url);
但是错误仍然存在。
open failed: EACCES (Permission denied)
我在我的 Firebase 控制台上收到了警报。
Your project's Cloud Firestore database '(default)' has insecure rules
当然,我已经允许对我的开发进行读写操作。
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read, write: if true;
}
}
}
补充说明:这是Firestore规则。奇怪的是,这些项目之前一直运行良好,但突然出现了错误。
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if true;
}
}
}
有没有解决方案?这是 Firebase 的错误吗? 如果有人能帮忙,我会很高兴的。