-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
firebase/firebase-js-sdk
#5453Labels
Description
Environment info
firebase-tools: 9.16.5
Platform: macOS
Test case
import firebase from 'firebase/app'
import 'firebase/storage'
if (!firebase.apps.length) {
firebase.initializeApp({
...
})
}
if (process.env.NODE_ENV === "development") {
firebase.firestore().useEmulator('localhost', 8080)
firebase.app().functions('europe-west1').useEmulator('localhost', 5001)
firebase.auth().useEmulator("http://localhost:9099")
firebase.storage().useEmulator("localhost", 9199)
}
function deleteImage(imageUrl: string) {
let urlRef = firebase.storage().refFromURL(imageUrl)
return urlRef.delete().catch((error) => console.error(error))
}
const imageUrl = "http://localhost:9199/v0/b/XXX.appspot.com/o/images%2Fdemo%2FHWEGgAPDSZrtMzbil2MwM.image%2Fjpeg?alt=media&token=a7f798ee-056a-4f03-a7bf-8453b71077e6"
deleteImage(imageUrl)
// storage.rules
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /images/{id}/{allPaths=**} {
allow read, write: if true;
}
}
}
Steps to reproduce
See test case above.
Expected behavior
Deleting the image based on the URL provided without error (same code snippet work in non-dev environment).
Actual behavior
I get the following error:
Uncaught FirebaseError: Firebase Storage: refFromUrl() expected a valid full URL but got an invalid one. (storage/invalid-argument)