- 1
- 5 641
Code11 Programming
Canada
เข้าร่วมเมื่อ 6 ก.พ. 2022
How to upload image to Google Drive using Node js
In this video, we learn how to upload images to Google Drive using Node.Js, as well as how to generate the static link for this image to be used in your application.
Project source code:
github.com/Elson0509/upload-Image-Google-Drive-and-Node-js
Project source code:
github.com/Elson0509/upload-Image-Google-Drive-and-Node-js
มุมมอง: 5 643
bro how to do with photos?
The url provided in this tutorial is broken due to some change in Google Drive. But don't despair. You need to extract another id from the url source code. I'm going to pass a code here that is working for me. You need to install axios and you need to have the imageid, which was provided by the video: const getViewerIdFromHTMLSourceCode = sourceCode => { if (!sourceCode) return null const splited = sourceCode.split('drive-viewer/') if (split.length < 2) return null const viewerId = splited[1].split('\\')[0] return viewerId } const getViewIdFromImageIdGoogleDrive = async photo_id => { try { const fetch = await axios.get(`drive.google.com/file/d/${photo_id}/view`) const viewid = getViewerIdFromHTMLSourceCode(fetch.data) return viewid } catch (err) { return null; } } With this code, use the getViewIdFromImageIdGoogleDrive function and put the photo_id as a parameter. You already have the photo_id, generated in this tutorial. This function returns a new id, in this case, which I call viewid. Then you use the following url lh3.googleusercontent.com/drive-viewer/[PUT THE VIEWID HERE] It's good to save this viewid in the database.
Thanks for your help! Subbed! I appreciate the help!
How can I put this project on github because if I put this project on google directly then googleKey.json file will go to public.
Awesome, thank you! This is the first building block for a great project!
The bessstt... Clear, simple, to the point, even for me that just starting code with nodejs... you deserve a medal.. 🏆
is there anyway to give permissions to specific emails after uploading the files ?
Thx a lot man! The best explanation such material! Very sad that you have only 12 subscribers.
Nice one man! found exactly what i was looking for.
Need more tutorials bro
You are the BEEEEEEST. Thank you so much. You even wrote the code precisely how I would have written it which made me happy. Thanks man.
Thank you. As an English learner, it is an honour to have a compliment.
<3
Really Thanks!