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));