Difficulty with adding files using HTTP request on meteor server side

From @Shultzi on Wed Nov 16 2016 08:23:56 GMT+0000 (UTC)

Good day,

Iā€™ve spent some time trying to upload file to ipfs using http request (from meteor).

Meteor.startup(() => {
  // code to run on server at startup
        Meteor.methods({
                "getFile": function(){
                        var results = HTTP.get('http://127.0.0.1:5001/api/v0/object/get', {timeout:5000, params:
                        {"arg": "QmcNHzJeDphzamLVgKq1R3wmFXqw8EbWLVS6qhAPGohobM",
                        "encoding": "json"}});
                        return (results)
                },
                "uploadFile": function(){
                        var results = HTTP.post("http://127.0.0.1:5001/api/v0/add", {timeout:5000, params:{
                        "path": "/home/shultzi/trial.txt",
                        "stream-channels": "true",
                        "arg": "/home/shultzi/trial.txt",
                        //"Content-Type": "multipart/mixed",
                        //"file": "trial.txt"
                        //"Content-Type": "multipart/form-data"

                        }, header: {
                        //"Content-Type": "application/octet-stream",
                        "enctype": "multipart/form-data",
                        "Content-Type": "multipart/form-data",
                        }});
                    return (results)
            }

    })
})

The first http request (getFile) works just fine, but when Iā€™m trying to upload the file I constantly get the error message ā€œFile argument ā€˜pathā€™ is requiredā€. Iā€™ve tried to modify my http request in many ways, adding stream-channels and changing multipart, but nothing seems to work.

I know thereā€™re some js apis out there, but I really want to work with my own http requests.

Iā€™ll highly appreciate any type of help, suggestion or insight you might have!

Copied from original issue: https://github.com/ipfs/support/issues/43

From @hsanjuan on Wed Nov 16 2016 11:38:16 GMT+0000 (UTC)

The way Iā€™d go to debug this is tcpdump using curl -F file=@/home/shultzi/trial.txt... to upload that file and then do the same using your code. Compare both dumps and see where is the difference.

The error would suggest that there is no ā€œfileā€ field in your multipart form-data, but would need to tcpdump to be sureā€¦