From 098f3a79013410ad73615034c6fff862033695b9 Mon Sep 17 00:00:00 2001 From: Sami Spets <savasp@utu.fi> Date: Mon, 30 Sep 2019 16:20:32 +0300 Subject: [PATCH] Debugging the server sent jpg --- web-service/client/src/Streams.js | 27 ++++++++++++++++++++++----- web-service/server/src/index.js | 8 ++++---- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/web-service/client/src/Streams.js b/web-service/client/src/Streams.js index e93fedd08..b809643be 100644 --- a/web-service/client/src/Streams.js +++ b/web-service/client/src/Streams.js @@ -30,21 +30,38 @@ const Streams = ({clearCookies}) => { } const renderThumbnails = async () => { + //updates all available thumbnail URIs const thumbs = await fetchThumbnails() - console.log('before', thumbnails) setThumbnails((thumbs)); - console.log('after', thumbnails) - return thumbnails + console.log(thumbnails[0]); + //Problem possibly here, it doesn't encode it correctly? + const encodedURL = encodeURI(thumbnails[0]); + console.log('ENCODED URL', encodedURL); + try{ + const someData = await fetch(`/stream/rgb?uri=${encodedURL}`) + if(!someData){ + throw new Error('Vitun vitun vittu'); + } + const myBlob = await someData.blob + console.log('MYBLOB', myBlob) + const objectURL = URL.createObjectURL(myBlob); + console.log('URL ', objectURL); + } catch(err){ + console.log('Kurwavaara:', err); + } + + return thumbnails; } + return( <div style={{'margin': 'auto', 'textAlign': 'center'}}> <h1>Streams component works!!</h1> <h2>Namibia here we come!</h2> <button onClick={clearCookies}>Logout</button> - <br /> - <button onClick={() => renderThumbnails()}></button> + <br/> + <button onClick={renderThumbnails}></button> </div> ) } diff --git a/web-service/server/src/index.js b/web-service/server/src/index.js index 47e78cfa8..93b2cefa2 100644 --- a/web-service/server/src/index.js +++ b/web-service/server/src/index.js @@ -169,17 +169,17 @@ app.get('/stream/depth', (req, res) => { //app.get('/stream', (req, res)) -/** +/* * Route for Google authentication API page -*/ + */ app.get('/google', passport.authenticate('google', { scope: ['profile'] })) -/** +/* * Google authentication API callback route. * Sets the JWT to clients browser and redirects the user back to front page (now has thumbnails). -*/ + */ app.get('/auth/google/redirect', passport.authenticate('google'), (req, res) => { console.log(req.user) const token = jwt.sign(req.user.id, keys.jwt.secret); -- GitLab