小编Fai*_*sal的帖子

如何使用云功能删除文件?

当我删除Firebase数据库中的帖子时,我希望云功能相应地删除firebase存储中的帖子缩略图.我的问题是,当我试图删除缩略图时,我认为我没有正确找到图像文件.

这是我尝试过的:

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
});
Run Code Online (Sandbox Code Playgroud)

这就是我在日志中得到的

ApiError:找不到Object.handleResp上的Object.parseHttpRespBody(/user_code/node_modules/@google-cloud/storage/node_modules/@google-cloud/common/src/util.js:192:30)(/ 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 /来自Request.self.callback的Request.inResponse [as _callback](/user_code/node_modules/@google-cloud/storage/node_modules/retry-request/index.js:120:7)的util.js:465:12(/ user_code/node_modules/@google-cloud/storage/node_modules/request/request.js:188:22)在requestTmit(events.js:191:7)的emitTwo(events.js:106:13)处.(/user_code/node_modules/@google-cloud/storage/node_modules/request/request.js:1171:10)在emit.ene(events.js:96:13)的Request.emit(events.js:188:7)

node.js firebase google-cloud-functions firebase-storage

15
推荐指数
4
解决办法
4521
查看次数

如何将列表中的每个其他项目设置为粗体?

我想像这样设计我的列表:

  1. 项目清单
  2. 项目清单
  3. 项目清单
  4. 项目清单
  5. 项目清单

^^你看到这里第一个是粗体,第二个是正常,第三个是粗体,依此类推.

我想在我的列表上动态地制作相同的东西.

html css

10
推荐指数
1
解决办法
1万
查看次数

如何在按下按钮时显示菜单而不是在os x中单击鼠标右键

当我将菜单分配给按钮时,当用户右键单击该按钮时,将显示菜单.

我想在用户左键单击按钮时打开菜单.

与此类似的东西:

在此输入图像描述


我使用此代码工作,但菜单显示在我的屏幕的右上角.我究竟做错了什么?

@IBOutlet var meeenu: NSMenu!
@IBAction func Options(sender: NSButtonCell) {
    meeenu.popUpMenuPositioningItem(meeenu.itemAtIndex(0), atLocation: NSEvent.mouseLocation(), inView: self.view)
}
Run Code Online (Sandbox Code Playgroud)

macos cocoa swift

2
推荐指数
1
解决办法
1837
查看次数