MCPcopy Index your code
hub / github.com/TruthHun/BookStack / AttachDelete

Method AttachDelete

controllers/ManagerController.go:792–816  ·  view source on GitHub ↗

删除附件.

()

Source from the content-addressed store, hash-verified

790
791// 删除附件.
792func (this *ManagerController) AttachDelete() {
793
794 attachId, _ := this.GetInt("attach_id")
795 if attachId <= 0 {
796 this.Abort("404")
797 }
798
799 attach, _ := models.NewAttachment().Find(attachId)
800 if attach.AttachmentId == 0 {
801 this.JsonResult(0, "ok")
802 }
803
804 obj := strings.TrimLeft(attach.FilePath, "./")
805 switch utils.StoreType {
806 case utils.StoreOss:
807 store.ModelStoreOss.DelFromOss(obj)
808 if bucket, err := store.ModelStoreOss.GetBucket(); err == nil {
809 bucket.SetObjectACL(obj, oss.ACLPrivate)
810 }
811 case utils.StoreLocal:
812 os.Remove(obj)
813 }
814 attach.Delete()
815 this.JsonResult(0, "ok")
816}
817
818// SEO管理
819func (this *ManagerController) Seo() {

Callers

nothing calls this directly

Calls 6

NewAttachmentFunction · 0.92
JsonResultMethod · 0.80
DelFromOssMethod · 0.80
GetBucketMethod · 0.80
FindMethod · 0.45
DeleteMethod · 0.45

Tested by

no test coverage detected