AWS S3在本机脚本上载失败

时间:2019-06-11 16:48:43

标签: amazon-s3 nativescript

我正在尝试将我的Nativescript应用程序与Amazon S3帐户连接,以便能够上传用户的个人资料图片。我为此使用Nativescript-aws-sdk插件。我收到的错误消息如下:“ The operation couldn’t be completed. (com.amazonaws.AWSS3TransferUtilityErrorDomain error 2.)

我用我的密钥和秘密密钥尝试了该插件,但这导致了相同的错误。我已经给我的S3帐户一个策略,并添加了CORS设置。我在做什么错了?

S3.init({ endPoint: '', accessKey: '', secretKey: '', type: 'static' }); // <= Try calling this before the app starts
const s = new S3();
const uploadingFileID = s.createUpload({
  file: filePath,
  bucketName: 'bucket',
  key: `1`,
  acl: 'public-read',
  completed: (error, success) => {
    if (error) {
      console.log(`Upload Failed :-> ${error.message}`);
    }
    if (success) {
      console.log(`Upload Complete :-> ${success.path}`);
    }
  },
  progress: progress => {
    console.log(`Upload Progress: ` + progress.value);
  }
});

0 个答案:

没有答案
相关问题