This is not a question, just a hint. Recently I wrote a program which
extracts attachments from multipart mime mails stored as files. I did 
this since there are often mails with many attachments (e.g., pictures),
and before all, they have unwanted filenames - windows-encoded, strange
characters, with blanks, 'JPEG' suffix instead of jpg if your scripts
work with 'jpg' files only ...

Makeing nice filenames (including RFC 2047 decoding) was not the problem.
However, some quirky mailers (e.g. web.de web mailer) do not have a
'filename' parameter in the 'Content-Disposition' header but only a 'name'
parameter in the 'Content-Type' header.

So in this case it is recommended to write

    mediaType, params, err = 
mime.ParseMediaType(part.Header.Get("Content-Type"))
    ...
    fn := part.FileName()
                   
    if len(fn) == 0 {
            fn = params["name"]
    }

And then fn can be 'niced' as you want; if fn is empty, a filename 
should be requested (otherwise, confirm the proposal).

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/649f49b1-d26d-4e08-8bd7-a16c2662166cn%40googlegroups.com.

Reply via email to