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