Home > Software design >  user does not have permission to access gs:// xxx.appspot.com
user does not have permission to access gs:// xxx.appspot.com

Time:03-30

In this application I created authencation, database with firebase. but in my post, which consists of title, content, and image, I only see my default image. I'm having a bit of a problem with storage in the database, first uploading the image to firebase storage and then taking its url.

import Foundation
import SwiftUI
import Firebase
import FirebaseStorage

class StorageStore: ObservableObject {
let storageRef = Storage.storage().reference()

    func uploadImage(_ image: UIImage, completion: @escaping (URL?) -> Void) {
        let imageRef = storageRef.child("images/" timeString() ".jpg")
        
        guard let imageData = image.jpegData(compressionQuality: 0.1) else {
            return completion(nil)
        }
        let metadata = StorageMetadata()
        metadata.contentType = "image/jpg"
        
        imageRef.putData(imageData, metadata: metadata, completion: { [self] (metadata, error) in
            if let error = error {
                assertionFailure(error.localizedDescription) //            
  • Related