 								path:	files[0].fd
 								size:	files[0].size
 							file: files[0].fd
-						return create(req, res)
+							file_inode: files[0].extra.fileId.toString()
+						return @create(req, res)
 					else
 						return res.badRequest 'Only 1 file attachment is allowed'
-			
+
 	# GET /msg/file/:id
 	getFile: (req, res) ->
 		Model = actionUtil.parseModel(req)

				else
					header = 'Accept-Ranges': 'bytes'
					if file.prop.length
						_.extend header,  
							'Content-Length': file.prop.length
							'Content-Range': "bytes 0-#{file.prop.length - 1}/#{file.prop.length}"
					res.set header
					res.attachment encodeURIComponent(file.prop.filename)
					file.stream.pipe(res)
			.catch res.serverError
			
	# GET /msg/file/thumb/:id
	getThumb: (req, res) ->
		Model = actionUtil.parseModel(req)

 # @help        :: See http://links.sailsjs.org/docs/controllers
_ = require 'lodash'
actionUtil = require 'sails/lib/hooks/blueprints/actionUtil'

module.exports =
	# POST /msg
	create: (req, res) ->
		Model = actionUtil.parseModel req
		data = actionUtil.parseValues(req);

		Model
			.create(data)
			.then (newInstance) ->
				Model
					.findOneById newInstance.id
					.populateAll()
			.then (newInstance) ->
				if req._sails.hooks.pubsub
					if req.isSocket
						Model.subscribe(req, newInstance);
						Model.introduce(newInstance);
					publishData = newInstance.toJSON()
					if _.isArray(newInstance)
						publishData = _.map newInstance, (instance) ->
							instance.toJSON()
					Model.publishCreate(publishData, !req.options.mirror && req);
				res.created(newInstance)
			.catch res.negotiate

	# POST /msg/file
	putFile: (req, res) ->
		req.file('file')
			.upload sails.config.file.opts, (err, files) =>
				if err
					return res.serverError(err)
				switch
