Skip to content

Commit

Permalink
Add sync routes for v3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
nemunaire committed Oct 17, 2023
1 parent 5b82b8c commit 7003494
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
29 changes: 29 additions & 0 deletions internal/app/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,35 @@ func (app *App) syncGetRootV3(c *gin.Context) {
})
}

func (app *App) blobStorageRead(c *gin.Context) {
uid := c.GetString(userIDKey)
blobID := common.ParamS(fileKey, c)

reader, _, size, err := app.blobStorer.LoadBlob(uid, blobID)
if err != nil {
log.Error(err)
c.AbortWithStatus(http.StatusInternalServerError)
return
}
defer reader.Close()

c.DataFromReader(http.StatusOK, size, "application/octet-stream", reader, nil)
}

func (app *App) blobStorageWrite(c *gin.Context) {
uid := c.GetString(userIDKey)
blobID := common.ParamS(fileKey, c)

_, err := app.blobStorer.StoreBlob(uid, blobID, c.Request.Body, 0)
if err != nil {
log.Error(err)
c.AbortWithStatus(http.StatusInternalServerError)
return
}

c.Status(http.StatusOK)
}

func (app *App) integrationsGetMetadata(c *gin.Context) {
var metadata messages.IntegrationMetadata
metadata.Thumbnail = ""
Expand Down
2 changes: 2 additions & 0 deletions internal/app/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,7 @@ func (app *App) registerRoutes(router *gin.Engine) {

authRoutes.GET("/sync/v3/root", app.syncGetRootV3)
authRoutes.PUT("/sync/v3/root", app.syncUpdateRootV3)
authRoutes.GET("/sync/v3/files/:"+fileKey, app.blobStorageRead)
authRoutes.PUT("/sync/v3/files/:"+fileKey, app.blobStorageWrite)
}
}

0 comments on commit 7003494

Please sign in to comment.