2017-05-15 10 views
0

URLリクエストのリンクをユーザー固有にする方法はありますか? Firebaseストレージファイルへの特定のリンクをユーザー固有のものにしようとしています。 xcodeまたはFirebaseストレージルールのコードを変更する必要がありますか?xcodeでURLリクエストを制限する

func yhandleDownload() { 
    print(123) 
    let webView = UIWebView (frame: view.frame) 
    webView.backgroundColor = UIColor.black 
    view.addSubview(webView) 
    webView.loadRequest(URLRequest(url: URL(string: "https://firebasestorage.googleapis.com")!)) 

    webView.scalesPageToFit = true 

私のコードが今設定されているので、アプリケーションにログインしているすべてのユーザーがリンクを開くことができます。お使いのセキュリティルールを適切に設定するよう

// Get the current user's UID 
let currentUser = FIRAuth.auth().currentUser?.uid 

// Reference to a user's image file in Firebase Storage 
let reference = storageRef.child("users/\(currentUser)/image.png") 

// UIImageView in your ViewController 
let imageView: UIImageView = self.imageView 

// Placeholder image 
let placeholderImage = UIImage(named: "placeholder.jpg") 

// Load the image using SDWebImage 
imageView.sd_setImage(with: reference, placeholderImage: placeholderImage) 

を同様に:

答えて

0

あなたが(例えば、ここで我々はまっすぐUIImageViewに画像をダウンロードするためにFirebaseUIを使用するつもり)のダウンロード方法で構築使用する必要があります。 the security rules docs

パー

service firebase.storage { 
    match /b/{bucket}/o { 
    match /users/{userId}/{allUserFiles=**} { 
     allow read, write: if request.auth.uid == userId; 
    } 
    } 
} 

関連する問題