lib/rackit.js
function (err, results) {
			if (err) {
				return cb(err);
			}

			// Generate file id
			var id = options.filename || utils.uid(24);

			//
			// Generate the headers to be send to Rackspace
			//

			var headers = {};
			// set the content-length of transfer-encoding as appropriate
			if (fromFile) {
				headers['content-length'] = results.stats.size;
			} else {
				if (source.headers && source.headers['content-length'])
					headers['content-length'] = source.headers['content-length'];
				else
					headers['transfer-encoding'] = 'chunked';
			}

			// Add any additonal headers
			var sKey;
			for (sKey in options.headers) {
				if (options.headers.hasOwnProperty(sKey)) {
					headers[sKey] = options.headers[sKey];
				}
			}

			//
			// Generate the cloud request options
			//
			var _options = {
				container : results.container.name,
				remote : id,
				headers : headers,
				metadata : options.meta,
				contentType : type
			};

			var readStream;
			if (fromFile)
				readStream = fs.createReadStream(source);
			else {
				readStream = source;
				source.resume();
				if (source.headers) {
					// We want to remove any headers from the source stream so they don't clobber our own headers.
					delete source.headers;
				}
			}

			var writeStream = o1._client.upload(_options);

			writeStream.on('error', cb);
			writeStream.on('success', function (file) {
				results.container.count++;
				cb(null, results.container.name + '/' + id);
			});

			readStream.pipe(writeStream);
		}
function (err, results) {
			if (err) {
				return cb(err);
			}

			// Generate file id
			var id = options.filename || utils.uid(24);

			//
			// Generate the headers to be send to Rackspace
			//

			var headers = {};
			// set the content-length of transfer-encoding as appropriate
			if (fromFile) {
				headers['content-length'] = results.stats.size;
			} else {
				if (source.headers && source.headers['content-length'])
					headers['content-length'] = source.headers['content-length'];
				else
					headers['transfer-encoding'] = 'chunked';
			}

			// Add any additonal headers
			var sKey;
			for (sKey in options.headers) {
				if (options.headers.hasOwnProperty(sKey)) {
					headers[sKey] = options.headers[sKey];
				}
			}

			//
			// Generate the cloud request options
			//
			var _options = {
				container : results.container.name,
				remote : id,
				headers : headers,
				metadata : options.meta,
				contentType : type
			};

			var readStream;
			if (fromFile)
				readStream = fs.createReadStream(source);
			else {
				readStream = source;
				source.resume();
				if (source.headers) {
					// We want to remove any headers from the source stream so they don't clobber our own headers.
					delete source.headers;
				}
			}

			var writeStream = o1._client.upload(_options);

			writeStream.on('error', cb);
			writeStream.on('success', function (file) {
				results.container.count++;
				cb(null, results.container.name + '/' + id);
			});

			readStream.pipe(writeStream);
		}
function ( err , results ) { if ( err ) { return cb ( err ) ; } // Generate file id var id = options . filename || utils . uid ( 24 ) ; // // Generate the headers to be send to Rackspace // var headers = { } ; // set the content-length of transfer-encoding as appropriate if ( fromFile ) { headers [ 'content-length' ] = results . stats . size ; } else { if ( source . headers && source . headers [ 'content-length' ] ) headers [ 'content-length' ] = source . headers [ 'content-length' ] ; else headers [ 'transfer-encoding' ] = 'chunked' ; } // Add any additonal headers var sKey ; for ( sKey in options . headers ) { if ( options . headers . hasOwnProperty ( sKey ) ) { headers [ sKey ] = options . headers [ sKey ] ; } } // // Generate the cloud request options // var _options = { container : results . container . name , remote : id , headers : headers , metadata : options . meta , contentType : type } ; var readStream ; if ( fromFile ) readStream = fs . createReadStream ( source ) ; else { readStream = source ; source . resume ( ) ; if ( source . headers ) { // We want to remove any headers from the source stream so they don't clobber our own headers. delete source . headers ; } } var writeStream = o1 . _client . upload ( _options ) ; writeStream . on ( 'error' , cb ) ; writeStream . on ( 'success' , function ( file ) { results . container . count ++ ; cb ( null , results . container . name + '/' + id ) ; } ) ; readStream . pipe ( writeStream ) ; }
Final function of parallel.. create the request to add the file
Final function of parallel .. create the request to add the file