cordova-plugin-mas-core
Version:
Cordova MAS Foundation Plugin
145 lines (123 loc) • 5.1 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: MASPluginMultipartForm.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: MASPluginMultipartForm.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>/*
* Copyright (c) 2016 CA, Inc. All rights reserved.
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*
*/
/**
* @class MASPluginMultipartForm
* @hideconstructor
* @classdesc A class to create and set Multipart form details for a POST request.
* <table>
* <tr bgcolor="#D3D3D3"><th>MASPluginMultipartForm Constructor</th></tr>
* <tr><td><i>var MASMultipartForm = new MASPlugin.MASMultipartForm();</td></tr>
* </table>
*/
var MASPluginUtils = require("./MASPluginUtils");
var MASPluginMultipartForm = function(){
this.formData = {},
this.files = [],
/**
* Allows to add key value pairs (ASCII) to the form data
* @memberOf MASPluginMultipartForm
* @function addFormData
* @instance
* @param {string} key The name of the attribute
* @param {string} value The value of the attribute
*/
this.addFormData = function(key, value){
if(!MASPluginUtils.isEmpty(key)){
this.formData[key] = value;
}
},
/**
* Adds a file object to the multipart form
* @deprecated
* @memberOf MASPluginMultipartForm
* @function addFiles
* @instance
* @param {string} fileName Name of the file to be uploaded
* @param {string} filePath Local path of the file on the SD/drive on the phone. The path should be accessible by native platform.
* @param {string} fileMimeType Type of the file ex. "text/plain" or "image/png" etc.
* @param {string} fileFieldName Field name in the multipart form request
* @param {string} fileData Base64 Encoded bytes of the file. If not available,make sure that filePath is on a readable path on card.
*/
this.addFiles = function(fileName,filePath,fileMimeType,fileFieldName,fileData){
let uploadFile =
{
"fileName":fileName,
"filePath":filePath,
"fileMimeType":fileMimeType,
"fileFieldName":fileFieldName,
"fileData":fileData
};
this.files.push(uploadFile);
},
/**
* Adds a file object to the multipart form
* @memberOf MASPluginMultipartForm
* @function addFiles
* @instance
* @param {string} fileName Name of the file to be uploaded
* @param {string} fileMimeType Type of the file ex. "text/plain" or "image/png" etc.
* @param {string} fileFieldName Field name in the multipart form request
* @param {string} fileData Base64 Encoded bytes of the file. If not available,make sure that filePath is on a readable path on card.
*/
this.addFiles = function(fileName,fileMimeType,fileFieldName,fileData){
let uploadFile =
{
"fileName":fileName,
"fileMimeType":fileMimeType,
"fileFieldName":fileFieldName,
"fileData":fileData
};
this.files.push(uploadFile);
},
/**
* Returns the final JavaScript Object representation of MASPluginMultipartForm in JSON format.
* @memberOf MASPluginMultipartForm
* @function getMultipartForm
* @instance
* @returns {Object} The MASPluginMultipartForm object.
*/
this.getMultipartForm = function(){
let finalForm = {
formData:this.formData,
files : this.files
};
return finalForm;
}
}
module.exports = MASPluginMultipartForm;</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="MASPlugin.html">MASPlugin</a></li><li><a href="MASPluginApplication.html">MASPluginApplication</a></li><li><a href="MASPluginAuthProviders.html">MASPluginAuthProviders</a></li><li><a href="MASPluginConstants.html">MASPluginConstants</a></li><li><a href="MASPluginDevice.html">MASPluginDevice</a></li><li><a href="MASPluginMAS.html">MASPluginMAS</a></li><li><a href="MASPluginMultipartForm.html">MASPluginMultipartForm</a></li><li><a href="MASPluginSecurityConfiguration.html">MASPluginSecurityConfiguration</a></li><li><a href="MASPluginUser.html">MASPluginUser</a></li><li><a href="MASPluginUtils.html">MASPluginUtils</a></li></ul><h3><a href="global.html">Global</a></h3>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.3</a> on Tue Feb 18 2020 21:13:36 GMT+0530 (India Standard Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>