为什么我的Nativescript应用程序无法使用'nativescript-aws-sdk'上传到S3?

时间:2019-11-22 07:06:20

标签: amazon-s3 nativescript

我正在尝试按照https://github.com/triniwiz/nativescript-aws-sdk的演示来上传图像,但是当我运行我的应用程序时,它会返回此错误

ERROR Error: java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/commons/logging/LogFactory; JS: com.amazonaws.AmazonWebServiceClient.<clinit>(AmazonWebServiceClient.java:65) JS: com.tns.Runtime.callJSMethodNative(Native Method) JS: com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1209) JS: com.tns.Runtime.callJSMethodImpl(Runtime.java:1096) JS: com.tns.Runtime.callJSMethod(Runtime.java:1083) JS: com.tns.Runtime.callJSMethod(Runtime.java:1063) JS: com.tns.Runtime.callJSMethod(Runtime.java:1055) JS: android.view.View.performClick(View.java:7327) JS: android.widget.TextView.performClick(TextView.java:14160) JS: android.view.View.performClickInternal(View.java:7299) JS: android.view.View.access$3200(View.java:846) JS: android.view.View$PerformClick.run(View.java:27773) JS: android.os.Handler.handleCallback(Handler.java:873) JS: android.os.Handler.dispatchMessage(Hand...

作为参考,这是我们的component.ts文件的外观:

export class BrowseComponent implements OnInit {
    constructor() {
        // Use the component constructor to inject providers.
    }

    ngOnInit(): void {
        // Use the "ngOnInit" handler to initialize data for the view.
        S3.init(<any>{
            endPoint: '',
            accessKey: 'our accessKey',
            secretKey: 'our secretKey',
            type: 'static' }); // <= Try calling this before the app starts
    }

export function uploadFile() {
  const s3 = new S3();
  const imageUploaderId = s3.createUpload({
    file: '~src/app/assets/Lena.jpg',
    bucketName: 'our bucketName',
    key: `ns__Lena.jpg`,
    acl: 'public-read',
    completed: (error, success) => {
      if (error) {
        console.log(`Download Failed :-> ${error.message}`);
      }
      if (success) {
        console.log(`Download Complete :-> ${success.path}`);
      }
    },
    progress: progress => {
      console.log(`Progress : ${progress.value}`);
    }
  });

  s3.pause(imageUploaderId);
  s3.resume(imageUploaderId);
  s3.cancel(imageUploaderId);

}

任何帮助将不胜感激。谢谢!

1 个答案:

答案 0 :(得分:1)

看来这是个问题for some time

从完全幼稚的角度来看,我建议在您的应用程序中安装log4j,因为这是找不到的软件包。显然,正确的解决方案是必须让插件为您做到这一点,但您自己动手即可解决问题。

相关问题