Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

193
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!