MCPcopy Create free account
hub / github.com/devld/go-drive / writeContent

Method writeContent

server/api_drive.go:414–442  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

412}
413
414func (dr *driveRoute) writeContent(c *gin.Context) {
415 path := utils.CleanPath(c.Param("path"))
416 d := c.MustGet("drive").(types.IDrive)
417
418 principal := GetPrincipal(c)
419 override := utils.ToBool(c.Query("override"))
420 defer func() { _ = c.Request.Body.Close() }()
421 tempFile, size, e := ReadRequestBodyToTempFile(c, dr.config.TempDir)
422 if e != nil {
423 _ = c.Error(e)
424 return
425 }
426 t, e := dr.runner.ExecuteAndWait(func(ctx types.TaskCtx) (any, error) {
427 defer func() {
428 _ = tempFile.Close()
429 _ = os.Remove(tempFile.Name())
430 }()
431 r, e := d.Save(ctx, path, size, override, tempFile)
432 if e != nil {
433 return nil, e
434 }
435 return dr.newEntryJson(r, principal), nil
436 }, 2*time.Second, task.WithNameGroup(path, "drive/write"))
437 if e != nil {
438 _ = c.Error(e)
439 return
440 }
441 SetResult(c, t)
442}
443
444func (dr *driveRoute) chunkUploadRequest(c *gin.Context) {
445 size := utils.ToInt64(c.Query("size"), -1)

Callers

nothing calls this directly

Calls 13

newEntryJsonMethod · 0.95
CleanPathFunction · 0.92
ToBoolFunction · 0.92
WithNameGroupFunction · 0.92
GetPrincipalFunction · 0.85
SetResultFunction · 0.85
CloseMethod · 0.65
ErrorMethod · 0.65
ExecuteAndWaitMethod · 0.65
NameMethod · 0.65
SaveMethod · 0.65

Tested by

no test coverage detected