@edgedev/firebase 2.1.57 → 2.1.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/edgeFirebase.js +14 -3
package/package.json
CHANGED
package/src/edgeFirebase.js
CHANGED
|
@@ -123,14 +123,17 @@ exports.toR2 = onObjectFinalized(
|
|
|
123
123
|
|
|
124
124
|
// Download file into memory from bucket.
|
|
125
125
|
const bucket = admin.storage().bucket(fileBucket)
|
|
126
|
-
|
|
127
|
-
const
|
|
126
|
+
|
|
127
|
+
const fileStream = bucket.file(filePath).createReadStream()
|
|
128
|
+
|
|
129
|
+
// const downloadResponse = await bucket.file(filePath).download()
|
|
130
|
+
// const file = downloadResponse[0]
|
|
128
131
|
|
|
129
132
|
// Upload the file to Cloudflare R2.
|
|
130
133
|
const params = {
|
|
131
134
|
Bucket: 'files',
|
|
132
135
|
Key: r2FilePath,
|
|
133
|
-
Body:
|
|
136
|
+
Body: fileStream,
|
|
134
137
|
ContentType: contentType,
|
|
135
138
|
}
|
|
136
139
|
const fileRef = bucket.file(filePath)
|
|
@@ -140,6 +143,14 @@ exports.toR2 = onObjectFinalized(
|
|
|
140
143
|
const orgId = event.data.metadata?.orgId
|
|
141
144
|
const docRef = db.collection(`organizations/${orgId}/files`).doc(fileDocId)
|
|
142
145
|
await docRef.set({ r2FilePath, r2URL, uploadCompletedToR2: true }, { merge: true })
|
|
146
|
+
|
|
147
|
+
// const base64Image = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/wcAAgAB/ax3OTkAAAAASUVORK5CYII='
|
|
148
|
+
// const imageBuffer = Buffer.from(base64Image, 'base64')
|
|
149
|
+
|
|
150
|
+
// await fileRef.save(imageBuffer, {
|
|
151
|
+
// contentType: 'image/png',
|
|
152
|
+
// })
|
|
153
|
+
|
|
143
154
|
const blankBuffer = Buffer.from('')
|
|
144
155
|
await fileRef.save(blankBuffer, {
|
|
145
156
|
contentType: 'application/octet-stream',
|