Handling URL POST submit Image


#1

I am getting started and could not find anything or anything that i understand on uploading POST submitted image in Meteor, is it supported right out of the box, if not how do i handle it?

So Far I Manage to break it down as:

  1. I need to make Server side Route to handle POST request (Not solid Idea on where to look for it)

  2. I need to use some kind of middleware for accepting POST Data (File/Image) [No Idea how to do it or where to look to learn it]

  3. Integrate Image Upload Meteor Package with that received Data and Upload the Image [with little playing around may be i can do it]

SO my question is how do i do, Step 1, 2 and 3, where do i have to look into? If its the bad approach please suggest me a good one.


#2

It’s hard to say exactly what you need without more specs but a good start is to look at IronRouter serverside routes. (if you’re using Iron Router… if not there are some less complex solutions).

https://github.com/iron-meteor/iron-router/blob/devel/Guide.md#server-routing?

Router.route('/resource/new', { where: 'server' })
  .post(function () {
    // reg node req/res object are avail.
    // this.request
    // this.response

  })

Are you uploading to your own server or something like amazon s3? If the latter there’s a few good s3 packages on atmosphere that let you do clientside/serverside uploads.

You can use node middleware by using it in the beforeEach

Router.onBeforeAction(function() {
  // middleware here
});

Hope this helps!