将图像上传到aws s3后,页面重新加载图像未找到,但下次是

After uploading image to aws s3, and the page reloads image is not found, but next time yes

我正在用户编辑个人资料页面上将图片上传到 s3, 它有效,但是在图像保存在 s3 中后,页面在保存更改后重新加载。

找不到图片,但是,如果我刷新页面,它就会出现...

任何想法可能是什么问题?

控制器中的这个应用程序:

exports.resize = async (req, res, next) => {
  // check if there is no new file to resize
  if (!req.file) {
    next(); // skip to the next middlewaree
    return;
  }
  const extension = req.file.mimetype.split('/')[1]
  req.body.photo = `${uuid.v4()}.${extension}`

  let readyimg
  const imageAws = await sharp(req.file.buffer)
    .resize(800, 800)
    .toBuffer()
    .then( data => {
      readyimg = data
    })

  AWS.config.update({
    secretAccessKey: process.env.SECRETACCESSKEY,
    accessKeyId: process.env.ACCESSKEYID,
    region: 'us-east-1'
  })

  const s3 = new AWS.S3()

  const params = {
    Bucket: 'jamsession-images',
    Key: req.body.photo,
    Body: readyimg
  };

  await s3.upload(params, function (err, data) {
    if (err) {
      console.log('%%%%%%%%%%%%%%% error in callback');
      console.log(err);
    }
    console.log('****************** success');
    console.log(data);
  });

  next()
};

它自己修复了...我想 aws bucket 在可用之前需要获得几个请求?