Skip to content

fix: correct Firebase Storage ref and public URL construction in uploadImage#263

Draft
Copilot wants to merge 5 commits into
mainfrom
copilot/add-file-extension-to-uploaded-media
Draft

fix: correct Firebase Storage ref and public URL construction in uploadImage#263
Copilot wants to merge 5 commits into
mainfrom
copilot/add-file-extension-to-uploaded-media

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 29, 2026

uploadImage received imageFolder as a full public URL (e.g. https://storage.googleapis.com/bucket/events/evt-1/) from filesPath.imageFolder, then passed it directly to Firebase's ref(storage, url). Firebase only recognises gs:// and firebasestorage.googleapis.com URLs — everything else is treated as a raw path string, causing the ref to point to a garbled location and the returned URL to be wrong.

Changes

  • src/utils/images/uploadImage.ts
    • Strip the bucket URL prefix from imageFolder before creating the ref(), handling both storage.googleapis.com/BUCKET/ and BUCKET.storage.googleapis.com/ formats
    • Return the public URL constructed from outputRef.fullPath, matching the https://BUCKET.storage.googleapis.com/PATH format used by the server-side uploadBufferToStorage
// Before
const outputRef = ref(storage, `${imageFolder}${fileName}`)  // imageFolder is a full URL → garbled ref
return `${imageFolder}${fileName}`

// After
const folderPath = imageFolder.startsWith(baseUrl) ? imageFolder.slice(baseUrl.length) : /* ... */ imageFolder
const outputRef = ref(storage, `${folderPath}${fileName}`)
return `https://${storageBucket}.storage.googleapis.com/${outputRef.fullPath}`

Copilot AI linked an issue May 29, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Add file extension for uploaded media files Normalize uploaded media filenames to a single detected extension May 29, 2026
Copilot AI requested a review from HugoGresse May 29, 2026 09:23
Copilot AI changed the title Normalize uploaded media filenames to a single detected extension Fix media storage paths to always end with the correct extension May 29, 2026
Copilot AI changed the title Fix media storage paths to always end with the correct extension fix: return actual public URL from PDF export instead of storage path May 29, 2026
Copilot AI changed the title fix: return actual public URL from PDF export instead of storage path fix: correct Firebase Storage ref and public URL construction in uploadImage May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add file extension to uploaded media

2 participants