AWS.util.Buffer.isBuffer不是一个函数

问题描述

请原谅我的无知,因为这是我第一次使用Amazon / S3。

我的任务是将一些旧代码移至Angular 9,当我遇到一个有趣的错误时,我正在将图像功能移至另一端。我通过NPM安装了aws-sdk软件包(最新版本2.742.0),这是我的图像调用:

_getImages(address: any) {
let observables = [];
this.imageUrlList.length = 0;
var albumBucketName = 'gibson-qa';
var AWS = require('aws-sdk');
var s3accessKeyId = 'keyhere';
var s3secretAccessKey = 'secretKeyHere';
var wasabiEndpoint = new AWS.Endpoint('https://s3.wasabisys.com');
var s3 = new AWS.S3({
  endpoint: wasabiEndpoint,region: 'us-east-1',version: 'latest',accessKeyId: s3accessKeyId,secretAccessKey: s3secretAccessKey,params: {
    Bucket: 'house-photos'
  }
});
var self = this;
var albumPhotosKey = 'uploads/' + address;

s3.listObjects({ Prefix: albumPhotosKey },function(err,data) {
  if (err) {
    console.log(err)
    return alert('There was an error viewing your album: ' + err.message);
  } else {
  // 'this' references the AWS.Response instance that represents the response
  var href = this.request.httpRequest.endpoint.href;
  console.log(href);
  var bucketUrl = href + albumBucketName + '/';
  console.log('bucket url: ' + bucketUrl);
  var photos = data.Contents.map((photo) => {
    var photoKey = photo.Key;
    // console.log('photo key: '+ photoKey);
    var photoUrl = bucketUrl + encodeURIComponent(photoKey);
    console.log('photo url: ' + photoUrl);
    self.imageUrlList.push(photoUrl);
  });
  console.log(self.imageUrlList);
  return self.imageUrlList;
  }
});

我收到的错误消息是AWS.util.Buffer.isBuffer is not a function

我已经在AWS文档中进行了一些挖掘,发现listOjbects函数具有V2。我已经尝试过使用它,但是仍然遇到相同的错误。

此代码在旧版代码库(aws-sdk 2.452.0版)中可以正常工作。

我们将不胜感激!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...