| 937 | } |
| 938 | |
| 939 | function 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 | |
| 960 | function request_response(res) { |
| 961 | |