जब मैं अपने फायरबेस डेटाबेस में कोई पोस्ट हटाता हूं, तो मैं चाहता हूं कि क्लाउड फ़ंक्शन फायरबेस स्टोरेज में पोस्ट के थंबनेल को मिटाने के लिए चाहता है। मेरा मुद्दा यह है कि जब मैं थंबनेल को हटाने की कोशिश कर रहा हूं, मुझे नहीं लगता कि मैं छवि फ़ाइल को सही ढंग से ढूंढ रहा हूं।क्लाउड फ़ंक्शंस का उपयोग कर फ़ाइल को कैसे हटाएं?
यहाँ मैं क्या करने की कोशिश की है:
const functions = require('firebase-functions')
const admin = require('firebase-admin')
const gcs = require('@google-cloud/storage')()
exports.deletePost = functions.database.ref('Posts/{pushId}').onWrite(event => {
const original = event.data.val()
const previous = event.data.previous.val()
const pushId = event.params.pushId
if (original === null)
return
const filePath = 'Posts/' + pushId + 'thumbnail.jpg'
const bucket = gcs.bucket('postsapp-12312')
const file = bucket.file(filePath)
const pr = file.delete()
return pr
});
यह है कि मैं क्या लॉग
ApiError: Not Found at Object.parseHttpRespBody (/user_code/node_modules/@google-cloud/storage/node_modules/@google-cloud/common/src/util.js:192:30) at Object.handleResp (/user_code/node_modules/@google-cloud/storage/node_modules/@google-cloud/common/src/util.js:132:18) at /user_code/node_modules/@google-cloud/storage/node_modules/@google-cloud/common/src/util.js:465:12 at Request.onResponse [as _callback] (/user_code/node_modules/@google-cloud/storage/node_modules/retry-request/index.js:120:7) at Request.self.callback (/user_code/node_modules/@google-cloud/storage/node_modules/request/request.js:188:22) at emitTwo (events.js:106:13) at Request.emit (events.js:191:7) at Request. (/user_code/node_modules/@google-cloud/storage/node_modules/request/request.js:1171:10) at emitOne (events.js:96:13) at Request.emit (events.js:188:7)
जिसे आप हटाने के लिए उपयोग करते हैं वह जीसीएस फ़ायरबेस फ़ंक्शन नहीं है। आप जीबीएस – vzhen
@ vzhen yes^के माध्यम से डीबी परिवर्तन को हटाने और हटाने के लिए फ़ंक्शंस का उपयोग कर रहे हैं^उस समय ऐसा करने का एकमात्र तरीका था, क्या अब कोई बदलाव आया है? क्या आप एक बेहतर जवाब दे सकते हैं? – Faisal
मैं भी देख रहा हूं। मैं फायरबेस स्टोरेज का उपयोग कर रहा हूं जीसीएस नहीं। ऐसा लगता है कि फायरबेस व्यवस्थापक एसडीके स्टोरेज सर्वर साइड डिलीट का समर्थन नहीं करता है। – vzhen