Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

433
Vistas
How can I fetch a public image from google drive using the File ID (not using node)

I'm trying to embed an image that's stored in my Google Drive onto my website. Here's the kicker: the File ID in question is not static, as my function always grabs the latest image in a list of form submissions.

I've fetched the preview URL from a Google Sheet of form responses using Apps Script. I've also sliced out the File ID using .replace() on the first part of the URL.

How can I grab the Image (which is public) from my google drive using this file ID and embed it?

Here's my code (omitting irrelevant info ofc):

const deskFeaturePhoto = document.querySelector('#featurePhoto')

fetch('https://script.google.com/macros/s/AKfycbwWFiL5Lg4J_JeTYAW_xyyH82ZStJYpKiJsBpBiJKT6XrjIYaDmpVOxCa-Jwt4iysNJoQ/exec?t=All%20Submissions')
  .then(res => res.json())
  .then((marketingQuery) => {
    deskFeaturePhoto.innerHTML = `<img src="https://drive.google.com/uc?export=view&id=${marketingQuery[marketingQuery.length-1].feature_image.replace('https://drive.google.com/open?id=', '')}" alt="Special Photo" style="width: 50%;">`
  }).catch(err => console.error(err))
<div id="featurePhoto" style="display: flex; flex-direction: column; align-items: center; justify-content: center;"></div>

This current 'solution' returns a 403 error despite displaying the image correctly when opening the image alone using the final URL.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Issue was reproduced on my end with no errors using sample code provided. This is most likely related to local Live Server issues, as requested sample code is here

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda