(e: Event)
| 26 | const storageRef = ref(storage); |
| 27 | |
| 28 | function handleFileSelect(e: Event) { |
| 29 | e.stopPropagation(); |
| 30 | e.preventDefault(); |
| 31 | |
| 32 | const target = e.target as HTMLInputElement | null; |
| 33 | const files = target?.files; |
| 34 | if (!target || !files) { |
| 35 | return; |
| 36 | } |
| 37 | |
| 38 | const file = files[0]; |
| 39 | |
| 40 | // Push to child path. |
| 41 | uploadBytes(ref(storageRef, 'images/' + file.name), file) |
| 42 | .then(function (snapshot) { |
| 43 | console.log('Uploaded', snapshot.metadata.size, 'bytes.'); |
| 44 | console.log('File metadata:', snapshot.metadata); |
| 45 | // Let's get a download URL for the file. |
| 46 | getDownloadURL(snapshot.ref).then(function (url) { |
| 47 | console.log('File available at', url); |
| 48 | linkBox.innerHTML = '<a href="' + url + '">Click For File</a>'; |
| 49 | }); |
| 50 | }) |
| 51 | .catch(function (error) { |
| 52 | console.error('Upload failed:', error); |
| 53 | }); |
| 54 | } |
| 55 | |
| 56 | fileInput.addEventListener('change', handleFileSelect, false); |
| 57 | fileInput.disabled = true; |
nothing calls this directly
no outgoing calls
no test coverage detected