Closed GoogleCodeExporter closed 8 years ago
You can simply let users to specify a mime.types config file that maps mime to
extension. Apache, nginx and the rest are doing similar thing.
weed volume -mime=/etc/mime.types ...
add mime according to mime.types file provided.
Use application/octet-stream for files without or unknown extension.
Original comment by claudiu....@gmail.com
on 11 Jul 2013 at 9:42
That's one way to detect the mime type. But this current issue is that I am
having trouble setting the mime type with Go's API. Need some coding help there.
Original comment by chris...@gmail.com
on 11 Jul 2013 at 9:55
[deleted comment]
ok, this seams to work for me.
Original comment by claudiu....@gmail.com
on 12 Jul 2013 at 1:47
Attachments:
Amazing! It worked well and I have checked it in to the HEAD!
Thanks Claudiu!
Original comment by chris...@gmail.com
on 12 Jul 2013 at 2:16
I'm glad!
However, there are few tweaks to add:
1. check if file name has an extension? If not, the file is text or binary?
2. some file names should be escaped (not sure how it is in Go)
3. mime.TypeByExtension is case insensitive? if not, string to lower?
4. file size > 0 ?
Original comment by claudiu....@gmail.com
on 12 Jul 2013 at 3:07
1. seems no extension still works? Default to binary? Need to investigate.
2. Not sure to escape for what purpose.
3. Done.
4. 0 size file should be a valid file. I tested. It still works fine.
Original comment by chris...@gmail.com
on 12 Jul 2013 at 4:31
Extension is a nice try, but for sure you should use some magic db like the
unix "file" command. A pure go implementation is bitbucket.org/taruti/mimemagic
- this would need the first 1024 bytes of the file data.
For the original question: use -v with curl to see what headers does it send;
use --trace-ascii to let it save to a file to be able to investigate what to
send.
Original comment by tgulacs...@gmail.com
on 12 Jul 2013 at 5:09
mime.TypeByExtension internally will also read the system mime settings.
Original comment by chris...@gmail.com
on 12 Jul 2013 at 5:59
Thomas, Thanks for the information. Very useful!
Original comment by chris...@gmail.com
on 12 Jul 2013 at 6:01
Original issue reported on code.google.com by
chris...@gmail.com
on 11 Jul 2013 at 7:00