FAQ
I am going to save image from url
but the problem is that I dont know how to get the image extensions to
exactly save to this kind of image type
eg: http://upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png
I want to save to file name by creating like this: file_name + "." +
file_extension

Anybody know how to make it,
I appreciate it

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Shawn Milochik at Nov 6, 2014 at 2:43 pm

    On Thu, Nov 6, 2014 at 9:38 AM, Hoai Ninh wrote:

    I am going to save image from url
    but the problem is that I dont know how to get the image extensions to
    exactly save to this kind of image type
    eg: http://upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png
    I want to save to file name by creating like this: file_name + "." +
    file_extension

    Anybody know how to make it,
    I appreciate it
    Does this help?
    http://golang.org/pkg/path/filepath/#Ext

    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Konstantin Khomoutov at Nov 6, 2014 at 2:53 pm

    On Thu, 6 Nov 2014 06:38:40 -0800 (PST) Hoai Ninh wrote:

    I am going to save image from url
    but the problem is that I dont know how to get the image extensions
    to exactly save to this kind of image type
    eg: http://upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png
    I want to save to file name by creating like this: file_name + "." +
    file_extension
    It's not quite clear what really about you're asking: do you want to
    extract the extension of the last path component of a known URI (like
    that one you've cited) or do you want to somehow "know" an extension
    for a file to save an image given its MIME type (like in image/png)?

    The first task can be carried out using the Ext() function of the
    path/filepath package while the latter can be done using a lookup map
    which associates known MIME types with extension strings.

    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Hoai Ninh at Nov 6, 2014 at 2:57 pm
    Thank for all your help

    It's ok to use the filepath.Ext() then using strings package to indicate
    file type
    On Thursday, November 6, 2014 9:38:40 PM UTC+7, Hoai Ninh wrote:

    I am going to save image from url
    but the problem is that I dont know how to get the image extensions to
    exactly save to this kind of image type
    eg: http://upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png
    I want to save to file name by creating like this: file_name + "." +
    file_extension

    Anybody know how to make it,
    I appreciate it
    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Shawn Milochik at Nov 6, 2014 at 4:37 pm

    On Thu, Nov 6, 2014 at 9:57 AM, Hoai Ninh wrote:

    Thank for all your help

    It's ok to use the filepath.Ext() then using strings package to indicate
    file type
    You can use DetectContentType to determine the mime type:
    http://golang.org/pkg/net/http/#DetectContentType

    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedNov 6, '14 at 2:38p
activeNov 6, '14 at 4:37p
posts5
users3
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase