exports.deleteItemImages = functions.firestore.document('items/{itemId}')
.onDelete(async (snap, context) => {
const deletedValue = snap.data();
const id = deletedValue.id;
if (id === null) {
return null;
}
console.log(`itemId to be deleted: ${id}`);
bucket.deleteFiles({
prefix: '${id}/'
}, function (err) {
if (!err) {
console.log(`Successfully deleted images with item id: ${id}`);
} else {
console.error(`Failed to remove images, error: ${err}`);
}
});
})
我有一个集合items
,每个文档都有一个字段id
。每个文档都有与之关联的图像,这些图像以相同的文件夹名称id
存储在Firebase存储中的目录(文件夹)中。删除各自的Firestore文档后,我想删除Firebase存储中的每个id
文件夹。在我的Firebase云功能日志中,行console.log(
成功删除的ID为$ {id} );
的图像已成功打印,但文件夹删除没有发生
编辑:我尝试手动输入prefix: '${id}/'
的文件夹名称,并且它起作用了。因此,连接到Firebase存储不是问题,尤其是该行。
答案 0 :(得分:0)
NVM。线
<cffunction name="sendMessageWithTwilio" output="false" access="public" returnType="string">
<cfargument name="aMessage" type="string" required="true" />
<cfargument name="destinationNumber" type="string" required="true" />
<cfset var twilioAccountSid = "YOUR_ACCOUNT_SID" />
<cfset var twilioAuthToken = "YOUR_AUTH_TOKEN" />
<cfset var twilioPhoneNumber = "YOUR_TWILIO_PHONE_NUMBER" />
<cfhttp
result="result"
method="POST"
charset="utf-8"
url="https://api.twilio.com/2010-04-01/Accounts/#twilioAccountSid#/Messages.json"
username="#twilioAccountSid#"
password="#twilioAuthToken#" >
<cfhttpparam name="From" type="formfield" value="#twilioPhoneNumber#" />
<cfhttpparam name="Body" type="formfield" value="#arguments.aMessage#" />
<cfhttpparam name="To" type="formfield" value="#arguments.destinationNumber#" />
</cfhttp>
<cfif result.Statuscode IS "201 CREATED">
<cfreturn deserializeJSON(result.Filecontent.toString()).sid />
<cfelse>
<cfreturn result.Statuscode />
</cfif>
</cffunction>
<cfdump var='#sendMessageWithTwilio(
"This is a test message.",
"+17775553333"
)#' />
应该是反引号,而不是单引号
-__-