Skip to content

Commit b2e5cd5

Browse files
feat(logo): use public access url for logo (#1363)
1 parent 71f61c9 commit b2e5cd5

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

next-tavla/src/Admin/utils/firebase.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { TConfig } from 'Admin/types/config'
22
import { TavlaError } from 'Admin/types/error'
33
import admin, { auth, firestore, storage } from 'firebase-admin'
4+
import { getDownloadURL } from 'firebase-admin/storage'
45
import { UidIdentifier } from 'firebase-admin/lib/auth/identifier'
56
import { chunk, concat, isEmpty } from 'lodash'
67
import { notFound } from 'next/navigation'
@@ -129,14 +130,11 @@ export async function setOrganizationLogo(logo: File, oid?: TOrganizationID) {
129130
const file = bucket.file(`logo/${oid}-${logo.name}`)
130131
file.save(Buffer.from(await logo.arrayBuffer()))
131132

132-
const logoUrl = await file.getSignedUrl({
133-
action: 'read',
134-
expires: '01-01-2100',
135-
})
133+
const logoUrl = await getDownloadURL(file)
136134

137-
if (!logoUrl || !logoUrl[0]) return
135+
if (!logoUrl) return
138136
return firestore().collection('organizations').doc(oid).update({
139-
logo: logoUrl[0],
137+
logo: logoUrl,
140138
})
141139
}
142140

0 commit comments

Comments
 (0)