Cordova FIle Transfer plugin how to pass transload

2019-08-30 09:00发布

问题:

Update Trying to post the file to transloadit using the FileTransfer plugin using the following code

     var uri = encodeURI("https://api2-eu-west-1.transloadit.com/assemblies");
            var options = new FileUploadOptions();
            options.fileKey = "file";
            options.fileName = filepath.substr(filepath.lastIndexOf('/') + 1);

            var params = new Object();
            params.auth =new Object();
            params.auth.key ="***************" ;

            options.params = params; 
            var ft = new FileTransfer();
            ft.upload(filepath, uri, win, fail, options);

I get the error "no_params_field", "No Params Field Provided" I also tried passing params as options

    ft.upload(filepath, uri, win, fail, params);

Can you please help how to send the transloadit params with the FileTransfer plugin?

Thanks

回答1:

Found it , It should be passed as

    var params = {};
            params.params = new Object();
            params.params.auth = {key: "***"};

Then

    ft.upload(filepath, uri, win, fail, {params: params});

Thanks