MCPcopy Index your code
hub / github.com/totaljs/framework / request_writefile

Function request_writefile

utils.js:939–958  ·  view source on GitHub ↗
(req, options, file, next)

Source from the content-addressed store, hash-verified

937}
938
939function request_writefile(req, options, file, next) {
940
941 var type = typeof(file.buffer);
942 var filename = (type === 'string' ? file.buffer : exports.getName(file.filename));
943
944 req.write((options.first ? '' : NEWLINE) + '--' + options.boundary + NEWLINE + 'Content-Disposition: form-data; name="' + file.name + '"; filename="' + filename + '"' + NEWLINE + 'Content-Type: ' + exports.getContentType(exports.getExtension(filename)) + NEWLINE + NEWLINE);
945
946 if (options.first)
947 options.first = false;
948
949 // Is Buffer
950 if (file.buffer && type === 'object') {
951 req.write(file.buffer);
952 next();
953 } else {
954 var stream = Fs.createReadStream(file.filename);
955 stream.once('close', next);
956 stream.pipe(req, STREAMPIPE);
957 }
958}
959
960function request_response(res) {
961

Callers 1

request_callFunction · 0.85

Calls 1

nextFunction · 0.70

Tested by

no test coverage detected