Code Monkey home page Code Monkey logo

Comments (4)

breautek avatar breautek commented on May 25, 2024

Are you sure you're using the upload api? For upload, the http method is forced to either PUT or POST.

See:

httpMethod = options.httpMethod || "POST";
if (httpMethod.toUpperCase() == "PUT"){
httpMethod = "PUT";
} else {
httpMethod = "POST";

from cordova-plugin-file-transfer.

allanevargas avatar allanevargas commented on May 25, 2024

@breautek Certain. This is my code:

this.fileTransfer.upload(imageData, encodeURI(url.replace('https', 'http') + 'pages/attachments.php'), options).then(data => {
    console.log(data);
}, error => {
    console.log(error);
});

from cordova-plugin-file-transfer.

breautek avatar breautek commented on May 25, 2024

On my app, I'm using version 1.7.2-dev, and it appears to work for me, at least for iOS and android. I have my own fork, and I am 4 commits behind Apache's master.

Note that this plugin is deprecated so there won't be any new releases or PRs merged in.

If you open up your project in Xcode (platforms/ios/) or Android Studio (platforms/android/), you should be able to set breakpoints to ensure the requests are being sent as a POST request from the native code.

from cordova-plugin-file-transfer.

phoenix503 avatar phoenix503 commented on May 25, 2024

Hi @breautek

Can you please suggest me the way how to add requestBody in fileTransfer plugin.
I am adding it in params but it is not working giving error as "Missing fields are required"

FileTransferError {code: 1, source: "content://com.android.providers.media.documents/document/document%3A33", target: "http://192.168.1.6:9001/protected/", http_status: 400, body: "<?xml version="1.0" encoding="UTF-8"?>↵<Error><Cod…34ec-b728-4fb5-a2fb-1beb859876db</HostId></Error>", …}body: "<?xml version="1.0" encoding="UTF-8"?>↵<Error><Code>MissingFields</Code><Message>Missing fields in request.</Message><BucketName>protected</BucketName><Resource>/protected/</Resource><RequestId>168FD184D26AB3F2</RequestId><HostId>f83934ec-b728-4fb5-a2fb-1beb859876db</HostId></Error>"code: 1exception: "http://192.168.1.6:9001/protected/"http_status: 400source: "content://com.android.providers.media.documents/document/document%3A33"target: "http://192.168.1.6:9001/protected/"__proto__: Object


    let options: FileUploadOptions = {
            fileKey: 'file',
            fileName: res[0].filename,
            httpMethod: res[0].http_method,
            params: requestBodyObj,
            chunkedMode: false
        };
        this.fileTransfer
            .upload(filePath, encodeURI(res[0].upload_url), options)
            .then(
                data => {
                    console.log(data);
                },
                err => {
                    console.log(err);
                }
            );

from cordova-plugin-file-transfer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.