diff --git a/api/api.go b/api/api.go index 88f9bc8..98ad926 100644 --- a/api/api.go +++ b/api/api.go @@ -69,12 +69,15 @@ func HandleUpload(resourceManager resource.Manager) gin.HandlerFunc { return } } + log.Printf("Uploading '%s'...", request.Path) + resourceManager.Upload(resource.UploadRequest{ Buffer: bytes.NewBuffer(content), Path: request.Path, MimeType: request.Properties.MimeType, Overwrite: request.Properties.Overwrite, }) + log.Printf("Uploaded '%s'", request.Path) // we return this as success c.Status(http.StatusNoContent) } @@ -85,10 +88,12 @@ func HandleCopy(resourceManager resource.Manager) gin.HandlerFunc { from := c.Query("from") to := c.Query("to") overwrite := c.Query("overwrite") == "true" + log.Printf("Copying from '%s' to '%s' (overwrite=%v)...", from, to, overwrite) if err := resourceManager.Copy(from, to, overwrite); err != nil { log.Println(err) c.AbortWithStatus(500) } else { + log.Printf("Done copyting from '%s' to '%s' (overwrite=%v)", from, to, overwrite) c.Status(201) } @@ -103,6 +108,8 @@ func HandlePresign(resourceManager resource.Manager) gin.HandlerFunc { c.AbortWithStatus(404) return } + log.Printf("Presigned '%s'", path) + if c.Query("redirect") == "true" { c.Redirect(http.StatusTemporaryRedirect, url) } else { @@ -114,8 +121,10 @@ func HandlePresign(resourceManager resource.Manager) gin.HandlerFunc { func HandleDownload(resourceManager resource.Manager) gin.HandlerFunc { return func(c *gin.Context) { path := c.Query("path") + log.Printf("Downloading '%s'...", path) data, err := resourceManager.Download(c, path) if err == nil { + log.Printf("Downloaded '%s'", path) c.Header("content-disposition", "inline; filename=\""+filename(path)+"\"") c.Data(200, readMimeType(path, ""), data) } else { @@ -127,9 +136,11 @@ func HandleDownload(resourceManager resource.Manager) gin.HandlerFunc { func HandleDelete(resourceManager resource.Manager) gin.HandlerFunc { return func(c *gin.Context) { path := c.Query("path") + log.Printf("Deleting '%s'...", path) if err := resourceManager.Delete(path); err != nil { c.AbortWithError(400, err) } else { + log.Printf("Deleted '%s'", path) c.Status(204) } }