I loop throw a list of files in Firebase storage and I would like to modify a string while looping,
Here is what I tried to do:
 var str;
 storage.bucket().file(...).download((err, content) => {
    str=content.toString();
    storage.bucket().getFiles(...).then(results => {
        const files = results[0];
        var promise = new Promise(function(resolve,reject){
           files.forEach(file => {
               ...
               str=str.replace("t","a");
           });
           resolve(str);
      });
      Promise.all(promise).then(function(str) {
        console.log(str); //NOT OKAY, the value is still "test" 
        file.save(str, function(err) { ... });
     });
I tried also :
promise.then(function(result) {
but it's the same result:(
UPDATE : I edited the code above but it still doesn't work :
Any idea?
UPDATE 2 :
it still doesn't work:(


 
    