删除附件.
()
| 790 | |
| 791 | // 删除附件. |
| 792 | func (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管理 |
| 819 | func (this *ManagerController) Seo() { |
nothing calls this directly
no test coverage detected