承诺不执行

时间:2018-03-03 17:01:40

标签: javascript promise

承诺未按预期执行。不知道我在这里做错了什么,然后承诺都没有执行。

exports.handler = (event, database, defaultBucket) => {
  if( event.data.val() ){
    const { userId, postId } = event.params;
    createFolderInTmp(postId);
    return event.data.ref.parent.once("value", ((snap) => {
      //getpostData data
      const postData = snap.val();
      var downloadPromises = [];
      const images = [];
      postData.slides.forEach(slide => {
          images.push(slide.value);
      });
      return Promise.all([
            ...images.map((image) => {
              return downloadImageAsync(image, postId, defaultBucket);
            })
          ])
       .then(() => {
//-----NEVER EXECUTES THIS STEP, SIMPLY GOES BLANK HERE----
          createAGIF(postData, postId);
          return console.log('this completed');
       })
       .then(() => {
          return uploadImageAsync( getLocalGIFFilePath(postId), getDestinationUrl(userId, postId) ,'image/gif',defaultBucket)
       })
       .then(() => {
          return updateShareableUrl(userId, postId, defaultBucket);
       });
    }));
  }else{
    console.log('No Data available');
    return false;
  }
};

添加相关功能

function downloadImageAsync(imageUrl, storyId, bucket){
   const tempFilePath = getTempDownloadUrl(storyId, encodeURIComponent(imageUrl));
   return bucket.file(imageUrl).download({ destination: tempFilePath});
}

有人可以指出我在这里做错了吗?

0 个答案:

没有答案