diff --git a/controller/files.go b/controller/files.go index 02a39a5..a78a11c 100644 --- a/controller/files.go +++ b/controller/files.go @@ -112,6 +112,25 @@ func (f *FilesController) GetStatusBy(cidString string) { f.respondJSON(&response.StatusResponse{Status: statusCode}) } + +func (f *FilesController) PostPinBy(cidString string) { + ctx := f.Ctx + + hashHex, valid := validateCid(cidString, true, ctx) + + if !valid { + return + } + + err := files.Pin(hashHex, getCurrentUserId(ctx)) + if internalError(ctx, err) { + logger.Get().Error(err.Error()) + return + } + + f.Ctx.StatusCode(iris.StatusCreated) +} + func validateCid(cidString string, validateStatus bool, ctx iris.Context) (string, bool) { _, err := cid.Valid(cidString) if sendError(ctx, err, iris.StatusBadRequest) {