Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
gulp-upload
Advanced tools
Use urllib to upload file to remote server.
npm install --save-dev gulp-upload
var gulp = require('gulp');
var upload = require('gulp-upload');
var options = {
server: 'http://192.168.0.77:7890/upload',
data: {
dirname: 'upload',
fileName: 'dest.js'
}
callback: function (err, data, res) {
if (err) {
console.log('error:' + err.toString());
} else {
console.log(data.toString());
}
}
}
gulp.task('upload', function() {
return gulp.src('server.js')
.pipe(upload(options));
});
var gulp = require('gulp')
var upload = require('gulp-upload')
var path = require('path')
var options = {
server: 'http://192.168.0.77:7890/upload',
data: {
fileName: function(file) {
return path.relative(__dirname, file.path)
}
}
}
gulp.task('watch', function () {
return watch('src/**/*.html')
.pipe(upload(options))
})
var express = require('express');
var skipper = require('skipper');
var app = express();
var port = 7890;
app.post('/upload', skipper());
app.post('/upload', function(req, res){
var body = req.body || {};
req.file('file').upload({
dirname: __dirname + body.dirname,
saveAs: body.fileName
},function (err, uploadedFiles) {
if (err) {
console.log(err.toString());
return res.status(500).send(err.toString())
} else {
return res.send('successfully!');
}
});
});
app.listen(port, function(){
port = (port !== '80' ? ':' + port : '');
var url = 'http://localhost' + port + '/';
console.log('Running at ' + url);
});
Option | Type | Description |
---|---|---|
server | ((string))(required) | Remote server to upload. |
data | ((object)) | The data will put in the field and send to server.If it is a function, it should return result. |
callback | ((function)) | It will be used in urllib. More |
MIT
FAQs
Upload file to remote server.
The npm package gulp-upload receives a total of 672 weekly downloads. As such, gulp-upload popularity was classified as not popular.
We found that gulp-upload demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.