| 188 | } |
| 189 | |
| 190 | func (c *Core) saveUploadFile(ctx *gin.Context, token *model.Token, data []byte, filename string, desc string, actions []string) (*model.Message, error) { |
| 191 | if len(data) <= 0 { |
| 192 | ctx.JSON(http.StatusNoContent, gin.H{"res": http.StatusNoContent, "msg": "no file content"}) |
| 193 | return nil, ErrNoContent |
| 194 | } |
| 195 | path, err := c.logic.SaveFile("files", data) |
| 196 | if err != nil { |
| 197 | ctx.JSON(http.StatusBadRequest, gin.H{"res": http.StatusBadRequest, "msg": "invalid file content"}) |
| 198 | return nil, ErrInvalidContent |
| 199 | } |
| 200 | return model.NewMessage(token).FileContent(path, filename, desc, len(data), actions), nil |
| 201 | } |
| 202 | |
| 203 | func (c *Core) makeTextContent(msg *model.Message, text string, title string, copytext string, autocopy string, actions []string) (*model.Message, error) { |
| 204 | var fname string |