ionic 4: Я хочу загрузить видеофайл с помощью Flow.js, но у меня ошибка - PullRequest
0 голосов
/ 23 октября 2018

Я могу забрать видеофайл из camera.getPicture (),
, но не могу загрузить файл (fileUri), используя this.upload () [Flow.js api].Я попытался снять видео и отправить файл (fileUri) на мой сервер с помощью Flowjs api,
, но ничего не происходит.

Мой Ionic Hybrid Android App logcat выглядит следующим образом:

10-23 14:48:17.291 22292-22292/io.ionic.starter D/CordovaActivity: Incoming Result. Request code = 18. 
10-23 14:48:17.291 22292-22292/io.ionic.starter D/CordovaInterfaceImpl: Sending activity result to plugin. 
10-23 14:48:17.291 22292-22292/io.ionic.starter D/CordovaActivity: Started the activity.  
10-23 14:48:17.291 22292-22292/io.ionic.starter D/CordovaActivity: Resumed the activity.  
10-23 14:48:17.326 22292-22292/io.ionic.starter D/dalvikvm: GC_FOR_ALLOC freed 1189K, 12% free 13758K/15604K, paused 32ms, total 33ms. 
10-23 14:48:17.351 22292-22490/io.ionic.starter D/CameraLauncher: File locaton is: /storage/emulated/0/DCIM/Camera/20181008_100932.mp4. 
10-23 14:48:17.441 22292-22494/io.ionic.starter D/[FilePath plugin]:: URI: /storage/emulated/0/DCIM/Camera/20181008_100932.mp4. 
10-23 14:48:17.446 22292-22494/io.ionic.starter D/[FilePath plugin]:: File - Authority: null, Fragment: null, Port: -1, Query: null, Scheme: null, Host: null, Segments: [storage, emulated, 0, DCIM, Camera, 20181008_100932.mp4]. 
10-23 14:48:17.456 22292-22292/io.ionic.starter W/IInputConnectionWrapper: showStatusIcon on inactive InputConnection. 

Это мой код ionic4:

    public start() {
        let options: CameraOptions = {
          quality: 50,
          destinationType: this.camera.DestinationType.FILE_URI,
          sourceType: this.camera.PictureSourceType.PHOTOLIBRARY,
          allowEdit: false,
          mediaType: this.camera.MediaType.VIDEO,
          // popoverOptions: CameraPopoverOptions,
          saveToPhotoAlbum: false};

        this.camera.getPicture(options)
          .then((fileUri)=> {



            this.path.resolveNativePath(fileUri)
                   .then((filePath)=>{
                     this.auth.presentAlert(filePath)
                     this.upload(filePath);                
                    },(err) => {
                      this.auth.presentAlert(err) ;
                    });


          }, 
          (err) => {
            this.auth.presentAlert(err.message) ;
          }) ;     
      }

      public upload(fileUri:string){

        var file: File = new File(null, fileUri, {})
        this.auth.presentAlert(file.name) ;

        const flow = new Flow({
          target: this.auth.apiHostUrl + '/upload',
          chunkSize: 300000,
          forceChunkSize: true,
          simultaneousUploads: 7,
          permanentErrors: [415, 500, 501]
        });

        flow.on('fileSuccess', (file, message) => {
          this.auth.presentAlert("upload success !!!")
          this.auth.hideLoading();
        });

        flow.on('fileError', (file, message) => {
          this.auth.presentAlert(message) ;
          this.auth.hideLoading();
        });

        flow.on('fileProgress', file => {
          if (flow.progress()) {
            this.loadProgress = Math.floor(flow.progress() * 100);
          }
        });

        flow.addFile(file) ;
        flow.upload() ;
        this.auth.showLoading() ;    
      }
    }
...