Volker Dobler
unread,Nov 11, 2011, 3:14:02 AM11/11/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
Is there a special reason why CreateFormFile() in package multipart
uses a fixed Content-Type of "application/octet-stream"?
I think this makes the "convenience wrapper around CreatePart"
very inconvenient as you cannot use it if you need a different
content type. Making the content type selectable by the user
would be straight forward and would still be convenient but more
flexible:
func (w *Writer) CreateFormFile(fieldname, filename, contentType
string) (io.Writer, os.Error) {
if contentType == "" {
contentType == "application/octet-stream"
}
...
}
// same result as with existing code:
CreateFormFile(field, filename, "")
// two (okay four) more lines of code to be more specific:
ext := ""
if i:=string.LastIndex(filename, "."); i!=.1 { ext = filename[i:] }
CreateFormFile(field, filename, mime.TypeByExtension(ext))
Regards, Volker