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

195
Visualizações
How can i resize already stored images in firebase?

I need to resize images stored in firebase, but these image are in differents folders like this:

-bucket  
  -user
    -images

i need to go to images of the certains users and i would like to apply this script to resize the images

const storage = await getStorage();
const bucketName = `$socialmediaAPG.appspot.com/userId/images/`;
const bucket = storage.bucket(bucketName);
const files = await bucket.getFiles();
for (const file of files[0]) {
  const isImage = file.name.toLowerCase().includes('jpg') || file.name.toLowerCase().includes('jpeg');
  const isThumb = file.name.toLowerCase().includes('thumbs');
  if (isImage && !isThumb) {
    console.info(`Copying ${file.name}`);
    const metadata = await file.getMetadata();
    await file.copy(file.name);
    await file.setMetadata(metadata[0]);
  }
}

i am getting this error:

Copying userId/images/image1.jpg Error: No such object: socialmediaAPG.appspot.com/userId/images/image1.jpg

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

This seems wrong:

file.copy(file.name)

The argument you pass to file.copy is the destination file name, so you're trying to copy the file onto itself.

You probably want to add your custom thumbs suffix to the destination file name with something like

file.copy(file.name+"thumbs")

For the actual resizing, I recommend checking out other questions on resizing images in Cloud Storage.

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