Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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 :

enter image description here

Any idea?

UPDATE 2 :

enter image description here

it still doesn't work:(

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
367 views
Welcome To Ask or Share your Answers For Others

1 Answer

Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...