feat(backend): implement on-demand thumbnail generation
Some checks failed
Build and Publish Docker Image / deploy (push) Failing after 44s
Some checks failed
Build and Publish Docker Image / deploy (push) Failing after 44s
When a thumbnail is requested but not yet available, attempt to generate it synchronously on-demand instead of immediately falling back to the placeholder image. - Export thumbnail generation helpers from the jobs package. - Update the Thumbnail handler to trigger on-demand generation if the thumbnail object is missing. - Save the updated box metadata with the new thumbnail reference. - Fall back to the placeholder image only if on-demand generation fails.
This commit is contained in:
@@ -141,6 +141,14 @@ func needsThumbnail(file services.File) bool {
|
||||
return file.PreviewKind == "image" || file.PreviewKind == "video" || isTextThumbnailCandidate(file)
|
||||
}
|
||||
|
||||
func NeedsThumbnail(file services.File) bool {
|
||||
return needsThumbnail(file)
|
||||
}
|
||||
|
||||
func GenerateThumbnailForFile(uploadService *services.UploadService, box services.Box, file services.File) (string, error) {
|
||||
return generateThumbnail(uploadService, box, file)
|
||||
}
|
||||
|
||||
func generateThumbnail(uploadService *services.UploadService, box services.Box, file services.File) (string, error) {
|
||||
thumbnailName := "@thumb@" + file.ID + ".jpg"
|
||||
object, err := uploadService.OpenFileObject(context.Background(), box, file)
|
||||
|
||||
Reference in New Issue
Block a user