我想与没有服务器的所有用户共享一些 json 文件,并且我使用 google firebase 存储服务(没有用户身份验证)。代码:
FirebaseStorage storage = FirebaseStorage.getInstance();
StorageReference storageRef = storage.getReferenceFromUrl("gs://xxxxxx.appspot.com/xxx-main.json");
Task<byte[]> task = storageRef.getBytes(1000000);
while (!task.isComplete())
StaticTools.sleep(100);
byte[] b=task.getResult();
但它引发了一个例外:
com.google.android.gms.tasks.RuntimeExecutionException: com.google.firebase.storage.StorageException: User does not have permission to access this object.
存储规则:
service firebase.storage {
match /b/XXXXXX.appspot.com/o {
match /{allPaths=**} {
allow read, write;
}
}
}