How to upload image to Google Drive using Node js

แชร์
ฝัง
  • เผยแพร่เมื่อ 18 พ.ย. 2024

ความคิดเห็น • 14

  • @code11programming
    @code11programming  10 หลายเดือนก่อน

    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.

  • @imamsibromuhlisi1520
    @imamsibromuhlisi1520 ปีที่แล้ว

    The bessstt... Clear, simple, to the point, even for me that just starting code with nodejs... you deserve a medal.. 🏆

  • @adriendridri8231
    @adriendridri8231 ปีที่แล้ว

    Awesome, thank you! This is the first building block for a great project!

  • @zowshow7982
    @zowshow7982 2 ปีที่แล้ว

    Thx a lot man! The best explanation such material! Very sad that you have only 12 subscribers.

  • @miraclehesed8959
    @miraclehesed8959 2 ปีที่แล้ว +1

    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.

    • @code11programming
      @code11programming  2 ปีที่แล้ว

      Thank you. As an English learner, it is an honour to have a compliment.

  • @edwinchan6521
    @edwinchan6521 ปีที่แล้ว

    Thanks for your help! Subbed! I appreciate the help!

  • @karanbhati2373
    @karanbhati2373 2 ปีที่แล้ว

    Nice one man! found exactly what i was looking for.

  • @razorjhon2622
    @razorjhon2622 ปีที่แล้ว

    is there anyway to give permissions to specific emails after uploading the files ?

  • @prasadkamble8302
    @prasadkamble8302 2 ปีที่แล้ว +1

    Need more tutorials bro

  • @ezequielmaquieira1234
    @ezequielmaquieira1234 2 ปีที่แล้ว

    Really Thanks!

  • @suanjjn9938
    @suanjjn9938 2 ปีที่แล้ว

  • @zerobyte64
    @zerobyte64 8 หลายเดือนก่อน

    bro how to do with photos?