MCPcopy
hub / github.com/moxiecode/plupload / FormData

Function FormData

js/moxie.js:4790–4881  ·  view source on GitHub ↗

FormData @class moxie/xhr/FormData @constructor

()

Source from the content-addressed store, hash-verified

4788 @constructor
4789 */
4790 function FormData() {
4791 var _blob, _fields = [];
4792
4793 Basic.extend(this, {
4794 /**
4795 Append another key-value pair to the FormData object
4796
4797 @method append
4798 @param {String} name Name for the new field
4799 @param {String|Blob|Array|Object} value Value for the field
4800 */
4801 append: function(name, value) {
4802 var self = this, valueType = Basic.typeOf(value);
4803
4804 // according to specs value might be either Blob or String
4805 if (value instanceof Blob) {
4806 _blob = {
4807 name: name,
4808 value: value // unfortunately we can only send single Blob in one FormData
4809 };
4810 } else if ('array' === valueType) {
4811 name += '[]';
4812
4813 Basic.each(value, function(value) {
4814 self.append(name, value);
4815 });
4816 } else if ('object' === valueType) {
4817 Basic.each(value, function(value, key) {
4818 self.append(name + '[' + key + ']', value);
4819 });
4820 } else if ('null' === valueType || 'undefined' === valueType || 'number' === valueType && isNaN(value)) {
4821 self.append(name, "false");
4822 } else {
4823 _fields.push({
4824 name: name,
4825 value: value.toString()
4826 });
4827 }
4828 },
4829
4830 /**
4831 Checks if FormData contains Blob.
4832
4833 @method hasBlob
4834 @return {Boolean}
4835 */
4836 hasBlob: function() {
4837 return !!this.getBlob();
4838 },
4839
4840 /**
4841 Retrieves blob.
4842
4843 @method getBlob
4844 @return {Object} Either Blob if found or null
4845 */
4846 getBlob: function() {
4847 return _blob && _blob.value || null;

Callers

nothing calls this directly

Calls 1

cbFunction · 0.85

Tested by

no test coverage detected