2

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 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.

Update

The reason I need to handle POST on my own is because i needed to upload images that are send by WYSIWYG text editors, many of them send the inline Images via POST url. Meteor-CollectionFS cannot be used with POST and I couldn't figure out how to integrate Meteor Upload with mapped POST URL and send the data to Meteor Upload for insert after receiving the file object at server.

monk
  • 4,727
  • 13
  • 45
  • 67

1 Answers1

1

Technically speaking you more or less have the idea of what you need to do. However, implementing image upload has a lot of nuances that will a) teach you quite a bit if you do decide to implement it on your own and b) will be a pain to implement yourself.

If all you want is a pretty robust, scalable, and customizable image upload solution I would suggest:

https://github.com/tomitrescak/meteor-uploads

It is build on top of the jquery file uploader, which is a very successful, maintained, and easy to use upload project. Alternatively, if you would like to upload to a Mongo GridFS you might want to look at:

https://github.com/CollectionFS/Meteor-CollectionFS

Both solutions are good but they each take a different approach to the problem. Each work pretty much out of the box but give plenty of room for configurability.

Tim C
  • 1,934
  • 12
  • 25
  • The reason i need to handle POST on my own is because i needed to upload images that are send by WYSIWYG text editors, many of them send the inline Images via POST url. Meteor-CollectionFS cannot be used with POST and i don't know how to use Meteor Upload with POST url, can you tell me how? – monk May 08 '15 at 05:42
  • Even if i use Meteor Upload then i still need to figure out Step 1 & 2 First to map the POST url and receive the submitted file data – monk May 08 '15 at 05:43
  • Those uploaders use a Multi-part POST method. In what was does the WYSIWYG send the inline img via POST? Is it also trying to send it via a multi-part? Can you get the browsers file object from the WYSIWYG? If so you can pass it into the CollectionFS methods. I guess I would just need more information about how the WYSIWYG handles the file. – Tim C May 08 '15 at 05:49
  • Tim, i am trying to use Redactor Text Editor with CollectionFS as well, in its guide it said how to handle upload http://imperavi.com/redactor/docs/upload-images/ I just could not figure out how to integrate both. CollectionFS primarily uses Event handlers to upload files – monk May 08 '15 at 05:55
  • Without testing this myself and trying to make an implementation of it. it is hard for me to give you a full answer. My guess is you have something like the example in the link you provided: $('#redactor').redactor({ imageUpload: ... }); With a bit of testing I think you should be able to add CollectionFS's FS.Utility.eachFile into the imageUpload method of the redactor and it will do what you would like. – Tim C May 08 '15 at 06:07
  • Is it possible to make something like, if post url is received at meteor, it would just pass the file object from post and invoke a template handler function and then pass that received file object inside event to FS Utility each file ?? – monk May 08 '15 at 06:16
  • the thing i don't understand is what is it that FS Utility each file really receiving as its argument 'Files', and where is it located at Request received from POST. – monk May 08 '15 at 06:19
  • in other words, how do i extract the 'files' from request received from POST, where is it located?? How can i retrieve it?? – monk May 08 '15 at 06:20
  • sorry, the 'each.file' receive Event Object, then it extract the Files from it but we can just omit the 'each.file' and use plain old for loop to loop over the received files but the real question is how do i retrieve that files from POST – monk May 08 '15 at 06:23