npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mft-upload

v1.0.21

Published

A REST utility for uploading file to a SOAP WebService. It is configurable and works as is with Oracle Managed file transfer (MFT).

Downloads

36

Readme

mft-upload

A simple REST utility for uploading files to a Managed File Transfer server or other file based integration servers, SaaS or PaaS cloud applications.

Use Cases

This packages exposes a REST interface to upload to MFT SOAP WebServices or arbitrary HTTP form applications. The utility works with Oracle Managed File Transfer server and uses payload templates so easily extensible to other use cases.

Implemented

  • SOAP inline XML or Binary base64 encoded data
  • Upload to SOAP service using SOAP attachments (SwA)
  • HTTP Formdata for upload to arbitray web apps
  • Chaining of requests for upload and notify SOAP service use cases
  • Custom payload templates using templatedir property
  • Allow removal of passwords from the config file
  • Support respfile argument for template development and improved debugging

Future use cases include the following:

  • Upload to HTTP servers using MTOM attachments

Prerequisites

It is assumed you have knowledge and a working MFT server installed such as Oracle MFT. The SOAP interface communicates with an MFT SOA or SOAP Source that must be configured on the MFT server that implements the MFT SOAP WSDL.

Installation

npm install mft-upload --save

Usage

Command Line

node upload.js file=index.js [config=req.json | passwords= debug=

file: Required pointer to the file to be uploaded.

config: Optional points to the config file described below. Default location is $HOME/.mft/upload.json

passwords: Optional space delimited array of passwords substituted into the config or templates

Config Files

The config file describes a request type and maximum file size at the root level. It also embedds and reuses the request type endpoint and authentication used by the HTTP Request package. A sample req.json shown below using Basic authentication is provided in the files folder. The request package supports many authentication types beyond what is shown below.

{
  "type": "SOAP",
  "maxsize": 20214400,
  "request": {
    "url": "http://HOSTNAME:7901/mftapp/services/transfer/SOAP2File",
    "method": "POST",
    "headers": { "Content-Type": "text/xml; charset=utf-8" },
    "auth": { "user": "USERNAME", "pass": "PASSWORD" }
  }
}

Following type support SOAP with Attachments.

{
  "type": "WSA",
  "maxsize": 5242880026214400,
  "request": {
    "uri": "http://HOSTNAME.com:7901/mftapp/services/transfer/SOAP2File",
    "method": "POST",
    "headers": {
       "FileName": "",
       "Content-Type": "multipart/related;type=\"text/xml\""
    },
    "multipart": [
       {
         "Content-Type": "text/xml;charset=UTF-8",
         "auth": { "user": "USERNAME", "pass": "PASSWORD" }
       },
       {
         "Content-Type": "application/octet-stream"
       }
    ]
  }
}

Config "template" allows user provided template using any file name or location.

{
  "type": "SOAP",
  "template": "my-payload", // template file is at "my-payload"
  "request": {
    "url": "http://localhost:7901/mftapp/services/transfer/SOAP2File",
    "method": "POST",
    "headers": { "Content-Type": "text/xml; charset=utf-8" },
    "auth": { "user": "USERNAME", "pass": "PASSWORD" }
  }
}

Config "templatedir" allows user provided template location of filename "-PAYLOAD"

{
  "type": "SOAP",
  "templatedir": "mytemplates", // template file is at "mytemplates/SOAP-PAYLOAD"
  "request": {
    "url": "http://localhost:7901/mftapp/services/transfer/SOAP2File",
    "method": "POST",
    "headers": { "Content-Type": "text/xml; charset=utf-8" },
    "auth": { "user": "USERNAME", "pass": "PASSWORD" }
  }
}

Illustrates chaining of requests using "cfgarr config array element for upload followed by a SOAP notification call.

{
  "type": "SOAP",
  "cfgarr": [
        { "config": "wsa.json", "file": "package.json"}
  ],
  "request": {
    "url": "http://HOSTNAME:7901/mftapp/services/transfer/SOAP2File",
    "method": "POST",
    "headers": { "Content-Type": "text/xml; charset=utf-8" },
    "auth": { "user": "USERNAME", "pass": "PASSWORD" }
  }
}

If a config argument is not provided, upload.js looks for one at ~/.mft/upload.json using process.argv[1].

Function getRequestConfig

Asyncronous function to process CLI arguments and get the config file

getRequestConfig(process.argv, function(err, retargs, cfgfile, cfgjson) {
  if (err) {
    console.log(err);
    process.exit(1);
  }
  args = retargs;
  filepath = args.file;
  reqOptions = cfgjson;
});

Function fileUpload

Asyncronous function to generate SOAP request and send it to the request endpoint URL

fileUpload(filepath, reqOptions, function(er, respcode, jsonbody, stats) {
  if (er) {
    console.log(er);
    process.exit(1);
  } 
  console.log('Response code is: ' +respcode);
  console.log(stats.summary);
});

Function upload

Async function that encapsulates getRequest and fileUpload into a single method.

Works with the config cfgarr element to chain requests.

upload(process.argv, function(err, respcode, jcfg, stats) {
  if (err) {
    console.log('Upload Error: ' +err);
    process.exit(1);
  };
});

Test

npm install chai

npm test

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

History

Created: May 6, 2015

Credits

Dave Berry A.K.A (bigfiles)

License

ISC