From 74af56b9cd269ce431b9fbfa85901e5bfe773161 Mon Sep 17 00:00:00 2001 From: ThibG Date: Fri, 27 Sep 2019 02:16:11 +0200 Subject: [Glitch] Use blob URL for Tesseract to avoid CORS issues Port 7baedcb61e15200478f3ad6deb96d452cd63499a to glitch-soc Signed-off-by: Thibaut Girka --- .../glitch/features/ui/components/focal_point_modal.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'app/javascript/flavours/glitch/features') diff --git a/app/javascript/flavours/glitch/features/ui/components/focal_point_modal.js b/app/javascript/flavours/glitch/features/ui/components/focal_point_modal.js index 8bded391a..d5c9e66ae 100644 --- a/app/javascript/flavours/glitch/features/ui/components/focal_point_modal.js +++ b/app/javascript/flavours/glitch/features/ui/components/focal_point_modal.js @@ -173,7 +173,17 @@ class FocalPointModal extends ImmutablePureComponent { langPath: `${assetHost}/ocr/lang-data`, }); - worker.recognize(media.get('url')) + let media_url = media.get('file'); + + if (window.URL && URL.createObjectURL) { + try { + media_url = URL.createObjectURL(media.get('file')); + } catch (error) { + console.error(error); + } + } + + worker.recognize(media_url) .progress(({ progress }) => this.setState({ progress })) .finally(() => worker.terminate()) .then(({ text }) => this.setState({ description: removeExtraLineBreaks(text), dirty: true, detecting: false })) -- cgit