Adding mime type for static files

32 views
Skip to first unread message

Weber A.

unread,
May 12, 2015, 10:13:00 AM5/12/15
to socket...@googlegroups.com
Hi,

I serving MS-Office documents out of the client/static directory. All files are served as type "application/octet-stream" which triggers IE to look deeper into the files and discover that they are ZIP files. Instead of opening the e.g. docx files in Word, they are now opened in the WinZIP.

To prevent IE from doing this, the server needs to send the correct mime type.

If I look into socketstream/lib/utils/serve-static.js I see that it exports "mime" which can be used to extend the list of mime types.

My problem now is, how can I access this "mime" from server.js?

Maybe someone can help me with that.

Thank you,
   Andreas

Robert Hall

unread,
May 28, 2015, 11:06:41 PM5/28/15
to socket...@googlegroups.com
That same file says it's for development purposes only. It doesn't appear mime is exposed to the SocketStream API, but it probably should be. I've opened a ticket to address it. https://github.com/socketstream/socketstream/issues/556

Henrik Vendelbo

unread,
Jun 1, 2015, 2:41:32 PM6/1/15
to socket...@googlegroups.com
Wouldn't we want to move away from implementing a general purpose app server?

I would expect that it is trivial to prepend a middleware which will serve special mime types. In production you should have the static server handle this anyway I would think.
Message has been deleted

Weber A.

unread,
Jul 9, 2015, 5:21:09 AM7/9/15
to socket...@googlegroups.com
How would you integrate this static server into an socketstream app? I'm currently looking into adding express to my app to handle the static files. However I'm not able to figure out how to do that. The examples I found look too different from my app:

var
http = require('http'),
  ss = require('socketstream');

var
mainClient = {
view: 'main.html',
css: ['libs'],
code: ['libs', 'app'],
tmpl: 'angular'
};

ss.client.define('main', mainClient);

var serveMain = function(req, res) {
res.serveClient('main');
};
ss.http.route('/', serveMain);

var
server = http.Server(ss.http.middleware);

server.listen(4000);

ss.start(server);

How would I integrate express into this?

Henrik Vendelbo

unread,
Oct 1, 2015, 8:59:32 AM10/1/15
to SocketStream
I'm making an Express example here. It will be for the upcoming SocketStream 0.5 release, but it the principles apply to the current release.

Reply all
Reply to author
Forward
0 new messages