Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

430
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda