0
这些是我的Firebase存储规则。新用户可以访问其他用户上传的照片
match
/{allPaths=**} {
allow read, write: if request.auth != null;
这是用户如何将图片添加到存储
StorageReference filepathOne = mStorage.child(user_data.getString("uidkey", null)).child("Photos").child("id_one");
正如你可以看到我使用的UID作为文件路径名的一部分。我的假设是,每当用户上传他们想要的图片时,只有他们能够访问它,因为他们拥有唯一的UID。但是,我创建了一个新的用户帐户,出于某种原因,该用户即使拥有不同的UID,也能够访问其他用户上传的照片。
我还应该指出,我将URI存储在sharedpref中,然后将其转换为字符串以显示图片。
这是我怎样存储在SharedPref
Uri downloadUrl = taskSnapshot.getDownloadUrl();
Picasso.with(getContext())
.load(downloadUrl)
.fit().centerCrop()
.into(image);
editor.putString(user_idone, (taskSnapshot.getDownloadUrl()).toString());
editor.commit();
这是我从县和显示提取。
Picasso.with(getContext())
.load(Uri.parse(user_data.getString("idonekey", null)))
.fit().centerCrop()
.into((ImageView) getView().findViewById(R.id.image));