I’m attempting to have my iOS app write to a non-default firebase Storage bucket known as “my_non_default_bucket”.
my_non_default_bucket has ‘stop public entry’ turned off, I added the [email protected] principal, firebase authentication is working within the app and the Storage rule is ‘request.auth != null’.
The app can write to the default bucket simply high quality however when I attempt to learn from a non-default bucket I get error “An unknown error occurred, please test the server response.”
Right here is the calling operate’s code:
do {
let uploadTask = strive await write_json_to_firebase_storage(knowledge: jsonData, path: json_path, filename: json_filename)
uploadTask?.observe(.success) { snapshot in
print("(#operate) Add accomplished")
}
uploadTask?.observe(.failure) { snapshot in
if let error = snapshot.error {
print("(#operate) Add failed with error: (error.localizedDescription)")
}
}
}catch{
print("(#operate) - Error writing JSON file: (error.localizedDescription)")
}
And right here is the operate that truly writes to storage bucket:
func write_json_to_firebase_storage(knowledge: Knowledge, path: String, filename: String) async throws -> StorageUploadTask? {
print("(#operate)")
let storage = Storage.storage(url: "gs://my_non_default_bucket")
let folderReference = storage.reference().little one(path)
let fileReference = folderReference.little one(filename)
// Add the JSON knowledge to Firebase Storage
let uploadTask = strive await fileReference.putData(knowledge, metadata: nil)
return uploadTask
}
If I merely take out the ‘url: “gs://my_non_default_bucket”‘ argument the app writes to the default bucket simply high quality.
It’s only with a customized bucket that it fails.
Any recommendation on what to search for within the customized bucket’s configuration or the place I can truly see the server response the error message is referring to can be enormously appreciated.
Thanks upfront.