Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gulp-upload

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-upload

Upload file to remote server.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
386
increased by105.32%
Maintainers
1
Weekly downloads
 
Created
Source

gulp-upload v1.0.0

Use urllib to upload file to remote server.

Install

npm install --save-dev gulp-upload

Example

client

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));
});

options.data

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))
})

server

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 || {};

  var options = {
    dirname: __dirname + (body.dirname || ''),
    saveAs: body.fileName
  };
  req.file('file').upload(options, function (err, uploadedFiles) {
    if (err) {
      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);
});

plugin options

OptionTypeDescription
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.
fileinputname((string))To define the name of API.

urllib options

https://github.com/node-modules/urllib#api-doc

License

MIT

Keywords

FAQs

Package last updated on 16 Aug 2017

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc