about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/features
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2019-09-27 02:16:11 +0200
committerThibaut Girka <thib@sitedethib.com>2019-09-30 15:58:29 +0200
commit74af56b9cd269ce431b9fbfa85901e5bfe773161 (patch)
tree8bfd46086b9b22434469ad49cca18df316f870cc /app/javascript/flavours/glitch/features
parent4b7c436ae9f2d8bcd274252a41c195f44da5ee26 (diff)
[Glitch] Use blob URL for Tesseract to avoid CORS issues
Port 7baedcb61e15200478f3ad6deb96d452cd63499a to glitch-soc

Signed-off-by: Thibaut Girka <thib@sitedethib.com>
Diffstat (limited to 'app/javascript/flavours/glitch/features')
-rw-r--r--app/javascript/flavours/glitch/features/ui/components/focal_point_modal.js12
1 files changed, 11 insertions, 1 deletions
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 }))