FAQ
Hi I'm so so sorry for the question

But I want to create a post request to hit a restful service and I need to
post the contents of a file (xml file)

I'm reading the file and trying to convert the []byte to an io.Reader.

Should I be doing that?

this is the error I get and wish to overcome :-)
[]byte does not implement io.Reader (missing Read method)

f.

--

Search Discussions

  • Jonathan Pittman at Dec 1, 2012 at 6:11 pm
    You can wrap it with a bytes.Reader.

    http://golang.org/pkg/bytes/#NewReader

    On Sat, Dec 1, 2012 at 12:49 PM, Francisco Diaz Trepat - gmail wrote:

    Hi I'm so so sorry for the question

    But I want to create a post request to hit a restful service and I need to
    post the contents of a file (xml file)

    I'm reading the file and trying to convert the []byte to an io.Reader.

    Should I be doing that?

    this is the error I get and wish to overcome :-)
    []byte does not implement io.Reader (missing Read method)

    f.

    --

    --
  • Francisco Diaz Trepat - gmail at Dec 1, 2012 at 6:29 pm
    thanks guys

    On Sat, Dec 1, 2012 at 3:11 PM, Jonathan Pittman wrote:

    You can wrap it with a bytes.Reader.

    http://golang.org/pkg/bytes/#NewReader


    On Sat, Dec 1, 2012 at 12:49 PM, Francisco Diaz Trepat - gmail <
    francisco.diaztrepat@gmail.com> wrote:
    Hi I'm so so sorry for the question

    But I want to create a post request to hit a restful service and I need
    to post the contents of a file (xml file)

    I'm reading the file and trying to convert the []byte to an io.Reader.

    Should I be doing that?

    this is the error I get and wish to overcome :-)
    []byte does not implement io.Reader (missing Read method)

    f.

    --

    --
  • Dustin Sallings at Dec 2, 2012 at 12:45 am
    Francisco Diaz Trepat - gmail
    <francisco.diaztrepat@gmail.com> writes:

    But I want to create a post request to hit a restful service and I
    need to post the contents of a file (xml file)

    I'm reading the file and trying to convert the []byte to an io.Reader.

    Should I be doing that?
    I wouldn't think so.

    Why do you read the file first? When you open the file, you have an
    io.Reader, why not just use that one as the body of the post?

    --
    dustin

    --

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedDec 1, '12 at 5:49p
activeDec 2, '12 at 12:45a
posts4
users3
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase