Skip to content

Commit c432b29

Browse files
authored
Remove the deprecated routes for PDF icons/thumbnails (#4358)
This route has been removed and added back several times as it was still used by some webapps. Let's try again.
2 parents 3c0e3da + cde026c commit c432b29

7 files changed

Lines changed: 6 additions & 252 deletions

File tree

docs/files.md

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,18 +1069,6 @@ parameter in the query-string (1 is the first page).
10691069
GET /files/download?Path=/Documents/hello.txt&Dl=1 HTTP/1.1
10701070
```
10711071

1072-
### GET /files/:file-id/icon/:secret
1073-
1074-
Get an image that shows the first page of a PDF in a small resolution (96x96).
1075-
1076-
**Note:** this route is deprecated, you should use thumbnails instead.
1077-
1078-
### GET /files/:file-id/preview/:secret
1079-
1080-
Get an image that shows the first page of a PDF (at most 1080x1920).
1081-
1082-
**Note:** this route is deprecated, you should use thumbnails instead.
1083-
10841072
### GET /files/:file-id/thumbnails/:secret/:format
10851073

10861074
Get a thumbnail of a file (for an image & pdf only). `:format` can be `tiny` (96x96)

docs/important-changes.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

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

7+
## April 2024: Routes for PDF
8+
9+
The deprecated routes for getting the icon or preview of a PDF file has been removed.
10+
11+
You should use the thumbnails instead.
12+
713
## December 2023: Iterations for PBKDF2 increased
814

915
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.

model/vfs/pdf.go

Lines changed: 0 additions & 178 deletions
This file was deleted.

pkg/jsonapi/data.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ type LinksList struct {
3939
Small string `json:"small,omitempty"`
4040
Medium string `json:"medium,omitempty"`
4141
Large string `json:"large,omitempty"`
42-
// Preview for PDF
43-
Preview string `json:"preview,omitempty"`
4442
}
4543

4644
// Relationship is a resource linkage, as described in JSON-API

web/files/files.go

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,56 +1055,6 @@ func HeadDirOrFile(c echo.Context) error {
10551055
return nil
10561056
}
10571057

1058-
// IconHandler serves icon for the PDFs.
1059-
func IconHandler(c echo.Context) error {
1060-
instance := middlewares.GetInstance(c)
1061-
1062-
secret := c.Param("secret")
1063-
fileID, err := vfs.GetStore().GetThumb(instance, secret)
1064-
if err != nil {
1065-
return WrapVfsError(err)
1066-
}
1067-
if c.Param("file-id") != fileID {
1068-
return jsonapi.NewError(http.StatusBadRequest, "Wrong download token")
1069-
}
1070-
1071-
doc, err := instance.VFS().FileByID(fileID)
1072-
if err != nil {
1073-
return WrapVfsError(err)
1074-
}
1075-
1076-
if err = CheckAntivirusAction(instance, doc, ActionPreview); err != nil {
1077-
return err
1078-
}
1079-
1080-
return vfs.ServePDFIcon(c.Response(), c.Request(), instance.VFS(), doc)
1081-
}
1082-
1083-
// PreviewHandler serves preview images for the PDFs.
1084-
func PreviewHandler(c echo.Context) error {
1085-
instance := middlewares.GetInstance(c)
1086-
1087-
secret := c.Param("secret")
1088-
fileID, err := vfs.GetStore().GetThumb(instance, secret)
1089-
if err != nil {
1090-
return WrapVfsError(err)
1091-
}
1092-
if c.Param("file-id") != fileID {
1093-
return jsonapi.NewError(http.StatusBadRequest, "Wrong download token")
1094-
}
1095-
1096-
doc, err := instance.VFS().FileByID(fileID)
1097-
if err != nil {
1098-
return WrapVfsError(err)
1099-
}
1100-
1101-
if err = CheckAntivirusAction(instance, doc, ActionPreview); err != nil {
1102-
return err
1103-
}
1104-
1105-
return vfs.ServePDFPreview(c.Response(), c.Request(), instance.VFS(), doc)
1106-
}
1107-
11081058
// ThumbnailHandler serves thumbnails of the images/photos
11091059
func ThumbnailHandler(c echo.Context) error {
11101060
instance := middlewares.GetInstance(c)
@@ -2204,8 +2154,6 @@ func Routes(router *echo.Group) {
22042154
router.POST("/upload/metadata", UploadMetadataHandler)
22052155
router.POST("/:file-id/copy", FileCopyHandler)
22062156

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

22112159
router.POST("/archive", ArchiveDownloadCreateHandler)

web/files/files_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3750,10 +3750,6 @@ func TestFiles(t *testing.T) {
37503750
data.ValueEqual("id", parentID)
37513751
data.Value("attributes").Object().ValueEqual("size", "90")
37523752
})
3753-
3754-
t.Run("DeprecatePreviewAndIcon", func(t *testing.T) {
3755-
testutils.TODO(t, "2026-05-01", "Remove the deprecated preview and icon for PDF files")
3756-
})
37573753
}
37583754

37593755
func readFile(fs vfs.VFS, name string) ([]byte, error) {

web/files/paginated.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -413,10 +413,6 @@ func (f *file) Links() *jsonapi.LinksList {
413413
links.Small = "/files/" + f.doc.DocID + "/thumbnails/" + f.thumbSecret + "/small"
414414
links.Medium = "/files/" + f.doc.DocID + "/thumbnails/" + f.thumbSecret + "/medium"
415415
links.Large = "/files/" + f.doc.DocID + "/thumbnails/" + f.thumbSecret + "/large"
416-
if f.doc.Class == "pdf" {
417-
links.Icon = "/files/" + f.doc.DocID + "/icon/" + f.thumbSecret
418-
links.Preview = "/files/" + f.doc.DocID + "/preview/" + f.thumbSecret
419-
}
420416
}
421417
}
422418
return &links

0 commit comments

Comments
 (0)