Git Product home page Git Product logo

Comments (8)

hacksparrow avatar hacksparrow commented on April 27, 2024

Multer 0.1.0 just released with busboy 0.2.6. Can you check with it?

from multer.

Siyfion avatar Siyfion commented on April 27, 2024

Nope, I've updated to v0.1.0 and I still get the same issue. Also updated to the latest express v4.3.2, etc.

from multer.

hacksparrow avatar hacksparrow commented on April 27, 2024

Can you paste the stack trace? I am suspecting something in Busboy.

from multer.

Siyfion avatar Siyfion commented on April 27, 2024

Sounds stupid, but there is no stack trace, I just get the error in my ExpressJS error handler with the error object:

error: [Error: Cannot switch to old mode now.]
error: An error occured when user sent the following request:
 URL:   POST http://localhost/static/images
 query: {}
 body:  {}

 Error: [Error: Cannot switch to old mode now.]

from multer.

Siyfion avatar Siyfion commented on April 27, 2024

Sorry @hacksparrow but I think I'm going to have to switch to using formidable for the time being as I cannot get this working at all... I'm really not sure what the hell happened though, it was working. Could it be due to the fact that I'm also using the Socket.IO library?

from multer.

Siyfion avatar Siyfion commented on April 27, 2024

Just to add to my last comment, I don't believe it's Socket.IO related, I stripped it out of my project entirely and the issue still persisted. Here's a full list of my dependencies, in case it might help in some way or other:

"dependencies": {
    "async": "~0.9.0",
    "aws-sdk": "~2.0.0-rc.19",
    "body-parser": "^1.3.0",
    "compression": "^1.0.3",
    "cors": "~2.3.1",
    "express": "~4.4.1",
    "gm": "~1.16.0",
    "hiredis": "^0.1.17",
    "lodash": "~2.4.1",
    "mongoose": "~3.8.12",
    "morgan": "^1.1.1",
    "multer": "0.1.0",
    "nodemailer": "~0.6.5",
    "passport": "^0.2.0",
    "passport-http": "^0.2.2",
    "password-hash": "^1.2.2",
    "redis": "^0.10.3",
    "socket.io": "^1.0.4",
    "twit": "~1.1.15",
    "validator": "~3.13.0",
    "winston": "~0.7.3",
    "winston-loggly": "^1.0.1"
  },
'use strict'

# Module dependencies.
express = require 'express'
http = require 'http'
sockets = require 'socket.io'
bodyParser = require 'body-parser'
multer  = require 'multer'
morgan  = require 'morgan'
compress = require 'compression'
cors = require 'cors'
passport = require 'passport'
winston = require 'winston'
error = require './middleware/errorHandling'

module.exports = () ->

  app = express()
  server = http.createServer(app)
  io = sockets.listen(server)

  app.set 'port', process.env.PORT or 3000

  winstonStream =
    write: (message, encoding) ->
      winston.info message

  app.use morgan stream: winstonStream
  app.use compress()
  app.use bodyParser()
  app.use multer()
  app.use cors()

    # origin: true
    # methods: ['GET', 'PUT', 'POST', 'DELETE']
    # credentials: true
    # maxAge: 3600

  # Add the passport authentication middleware
  app.use passport.initialize()

  # Ensure that all routes are authenticated, except the route
  # that gets the user count for a given site
  authentication = passport.authenticate 'basic', session: false
  app.use (req, res, next) ->
    if (req.url.indexOf('/sites/') is 0 and
      req.url.indexOf('/userCount', req.url.length - '/userCount'.length) isnt -1) or
      req.url.indexOf('/twitter/userTimeline') is 0
        next()
      else
        authentication(req, res, next)

  # Configure the routes
  require('./routes.js')(app)

  # Configure the web socket listeners
  require('./web_sockets')(io)

  app.use error.handle404
  app.use error.logErrors
  app.use error.apiErrors

  winston.info "Express server listening on port: #{app.get('port')}"
  server.listen app.get('port')

from multer.

Siyfion avatar Siyfion commented on April 27, 2024

@hacksparrow BINGO! I've figured it out...

It seems to be related to my cors library.

Changing:

  app.use morgan stream: winstonStream
  app.use compress()
  app.use bodyParser()
  app.use multer()
  app.use cors()

to:

  app.use morgan stream: winstonStream
  app.use cors()
  app.use compress()
  app.use bodyParser()
  app.use multer()

(note the ordering!) fixes the issue.

from multer.

hacksparrow avatar hacksparrow commented on April 27, 2024

Glad you got it working!

from multer.

Related Issues (20)

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.