MCPcopy Create free account
hub / github.com/chanify/chanify / saveUploadFile

Method saveUploadFile

core/sender.go:190–201  ·  view source on GitHub ↗
(ctx *gin.Context, token *model.Token, data []byte, filename string, desc string, actions []string)

Source from the content-addressed store, hash-verified

188}
189
190func (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
203func (c *Core) makeTextContent(msg *model.Message, text string, title string, copytext string, autocopy string, actions []string) (*model.Message, error) {
204 var fname string

Callers 3

ParseFormDataMethod · 0.80
TestSaveFileFunction · 0.80
TestSaveFileFailedFunction · 0.80

Calls 4

NewMessageFunction · 0.92
SaveFileMethod · 0.80
FileContentMethod · 0.80
JSONMethod · 0.65

Tested by 2

TestSaveFileFunction · 0.64
TestSaveFileFailedFunction · 0.64