Coder Social home page Coder Social logo

thedgmbh / multi-rest Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 1.0 53 KB

A middleware to handle multi-part request for restify

Home Page: https://www.npmjs.com/package/multi-rest

License: MIT License

JavaScript 100.00%
multi-rest restify nodejs npm npm-package multipart api

multi-rest's People

Contributors

ahmed-agiza avatar amragaey avatar haiderghaleb avatar mmahrous avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

multi-rest's Issues

Error: spawn convert ENOENT

Hi,

I have the following code: (minimal version of read me file)

const restify = require('restify');
const Multi = require('multi-rest');
const uuidv4 = require('uuid/v4');

const server = restify.createServer();
server.use(restify.plugins.bodyParser());

const upload_disk = new Multi({
    driver: {
        type: 'local',
        path: "./uploads/"
    },
    filename: (name) => `${name}_${uuidv4()}`,
    filefields: {
        image: {
            type: 'picture',
            thumbnail: {
                width: 400,
                height: 300
            },
            required: false,
            extensions: ['png', 'jpg']
        }
    },
});

server.post('/v/1/file',
    upload_disk,
    (req, res) => res.send({
        success: true,
        files: req.files,
        message: "file uploaded :)"
    }));

server.listen(3010, () => console.log('%s listening at %s', server.name, server.url))

Whenever I try to upload an image, the app crashes and throws the following error:

events.js:182
      throw er; // Unhandled 'error' event
      ^

Error: spawn convert ENOENT
    at _errnoException (util.js:1026:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:192:19)
    at onErrorNT (internal/child_process.js:374:16)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickDomainCallback (internal/process/next_tick.js:218:9)

Request screen shot from postman:

screen shot 2017-09-24 at 2 19 50 pm

Please advice if I am missing something.

Folder is not created

Hi there,

The folder is not created "uploads" and I got File object in req.files.file, File path is "/var/folders/82/3s2yq3zj77l3xn1xvy9pgfx40000gn/T/upload_6bcd336e42b32122a8ed682e52ab".
I use restify.

var upload_disk = new Multi({
  driver: {
      type: 'local',
      path: "uploads/"
  },
  filename: (name) => {
      return uuid.v4();
  },
  filefields: {
      image: {
          type: 'file',
          thumbnail: {
              width: 400,
              height: 300
          },
          required: false,
          extensions: ['png', 'jpg']
      }
  }
});

server.post({ path: "photo", version }, upload_disk, this.savePhoto.bind(this))

savePhoto(req, res, next) {
    console.log('FILE: ', req.files.file)

    res.json(200, {})
    return next()
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.