Skip to content

Commit

Permalink
Remove the deprecated routes for PDF icons/thumbnails
Browse files Browse the repository at this point in the history
This reverts commit ab50d83.
  • Loading branch information
nono committed Mar 26, 2024
1 parent 3b9b252 commit 5d3b3ec
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 244 deletions.
12 changes: 0 additions & 12 deletions docs/files.md
Original file line number Diff line number Diff line change
Expand Up @@ -935,18 +935,6 @@ By default the `content-disposition` will be `inline`, but it will be
GET /files/download?Path=/Documents/hello.txt&Dl=1 HTTP/1.1
```

### GET /files/:file-id/icon/:secret

Get an image that shows the first page of a PDF in a small resolution (96x96).

**Note:** this route is deprecated, you should use thumbnails instead.

### GET /files/:file-id/preview/:secret

Get an image that shows the first page of a PDF (at most 1080x1920).

**Note:** this route is deprecated, you should use thumbnails instead.

### GET /files/:file-id/thumbnails/:secret/:format

Get a thumbnail of a file (for an image & pdf only). `:format` can be `tiny` (96x96)
Expand Down
6 changes: 6 additions & 0 deletions docs/important-changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

This section will list important changes to the stack or its usage, and migration procedures if any is needed.

## April 2024: Routes for PDF

The deprecated routes for getting the icon or preview of a PDF file has been removed.

You should use the thumbnails instead.

## December 2023: Iterations for PBKDF2 increased

We have increased the number of PBKDF2 iterations for new users to 650_000, and removed the exception for Edge as it now supports PBKDF2 via the subtle crypto API.
Expand Down
178 changes: 0 additions & 178 deletions model/vfs/pdf.go

This file was deleted.

2 changes: 0 additions & 2 deletions pkg/jsonapi/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ type LinksList struct {
Small string `json:"small,omitempty"`
Medium string `json:"medium,omitempty"`
Large string `json:"large,omitempty"`
// Preview for PDF
Preview string `json:"preview,omitempty"`
}

// Relationship is a resource linkage, as described in JSON-API
Expand Down
44 changes: 0 additions & 44 deletions web/files/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -992,48 +992,6 @@ func HeadDirOrFile(c echo.Context) error {
return nil
}

// IconHandler serves icon for the PDFs.
func IconHandler(c echo.Context) error {
instance := middlewares.GetInstance(c)

secret := c.Param("secret")
fileID, err := vfs.GetStore().GetThumb(instance, secret)
if err != nil {
return WrapVfsError(err)
}
if c.Param("file-id") != fileID {
return jsonapi.NewError(http.StatusBadRequest, "Wrong download token")
}

doc, err := instance.VFS().FileByID(fileID)
if err != nil {
return WrapVfsError(err)
}

return vfs.ServePDFIcon(c.Response(), c.Request(), instance.VFS(), doc)
}

// PreviewHandler serves preview images for the PDFs.
func PreviewHandler(c echo.Context) error {
instance := middlewares.GetInstance(c)

secret := c.Param("secret")
fileID, err := vfs.GetStore().GetThumb(instance, secret)
if err != nil {
return WrapVfsError(err)
}
if c.Param("file-id") != fileID {
return jsonapi.NewError(http.StatusBadRequest, "Wrong download token")
}

doc, err := instance.VFS().FileByID(fileID)
if err != nil {
return WrapVfsError(err)
}

return vfs.ServePDFPreview(c.Response(), c.Request(), instance.VFS(), doc)
}

// ThumbnailHandler serves thumbnails of the images/photos
func ThumbnailHandler(c echo.Context) error {
instance := middlewares.GetInstance(c)
Expand Down Expand Up @@ -1922,8 +1880,6 @@ func Routes(router *echo.Group) {
router.POST("/upload/metadata", UploadMetadataHandler)
router.POST("/:file-id/copy", FileCopyHandler)

router.GET("/:file-id/icon/:secret", IconHandler)
router.GET("/:file-id/preview/:secret", PreviewHandler)
router.GET("/:file-id/thumbnails/:secret/:format", ThumbnailHandler)

router.POST("/archive", ArchiveDownloadCreateHandler)
Expand Down
4 changes: 0 additions & 4 deletions web/files/files_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3614,10 +3614,6 @@ func TestFiles(t *testing.T) {
data.ValueEqual("id", parentID)
data.Value("attributes").Object().ValueEqual("size", "90")
})

t.Run("DeprecatePreviewAndIcon", func(t *testing.T) {
testutils.TODO(t, "2024-05-01", "Remove the deprecated preview and icon for PDF files")
})
}

func readFile(fs vfs.VFS, name string) ([]byte, error) {
Expand Down
4 changes: 0 additions & 4 deletions web/files/paginated.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,10 +389,6 @@ func (f *file) Links() *jsonapi.LinksList {
links.Small = "/files/" + f.doc.DocID + "/thumbnails/" + f.thumbSecret + "/small"
links.Medium = "/files/" + f.doc.DocID + "/thumbnails/" + f.thumbSecret + "/medium"
links.Large = "/files/" + f.doc.DocID + "/thumbnails/" + f.thumbSecret + "/large"
if f.doc.Class == "pdf" {
links.Icon = "/files/" + f.doc.DocID + "/icon/" + f.thumbSecret
links.Preview = "/files/" + f.doc.DocID + "/preview/" + f.thumbSecret
}
}
}
return &links
Expand Down

0 comments on commit 5d3b3ec

Please sign in to comment.