FAQ
Hi,

I'm using MultipartReader to process file uploads. When I Read from the
Part it only gets back 4055 bytes at a time instead of filling my buffer
(which is 5 MiB).

While I'm sure I can work around this, I'd like to understand why it's
happening. Am I misunderstanding how Read works? Is it a limit in
MultipartReader? Is it just a matter of how much data has been received
from the browser? I don't understand.

I put together a simplified example to demonstrate what's happening. I'm
running Go 1.4.2.
https://github.com/nathany/multipart

Thanks,
Nathan.

--
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

  • Jesse McNelis at Feb 19, 2015 at 2:42 am

    On Thu, Feb 19, 2015 at 1:12 PM, Nathan Youngman wrote:
    I'm using MultipartReader to process file uploads. When I Read from the Part
    it only gets back 4055 bytes at a time instead of filling my buffer (which
    is 5 MiB).
    Read the documentation for io.Reader
    http://golang.org/pkg/io/#Reader

    You probably want to use http://golang.org/pkg/io/#ReadFull

    --
    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.
  • Nathan Youngman at Feb 19, 2015 at 2:58 am
    Thanks Jesse,

    This must be the key I was missing:

    "If some data is available but not len(p) bytes, Read conventionally
    returns what is available instead of waiting for more."

    I'll give ReadFull a try.

    Nathan.
    On Wednesday, 18 February 2015 19:42:48 UTC-7, Jesse McNelis wrote:

    On Thu, Feb 19, 2015 at 1:12 PM, Nathan Youngman <junk...@nathany.com
    <javascript:>> wrote:
    I'm using MultipartReader to process file uploads. When I Read from the Part
    it only gets back 4055 bytes at a time instead of filling my buffer (which
    is 5 MiB).
    Read the documentation for io.Reader
    http://golang.org/pkg/io/#Reader

    You probably want to use http://golang.org/pkg/io/#ReadFull
    --
    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
postedFeb 19, '15 at 2:12a
activeFeb 19, '15 at 2:58a
posts3
users2
websitegolang.org

2 users in discussion

Nathan Youngman: 2 posts Jesse McNelis: 1 post

People

Translate

site design / logo © 2022 Grokbase