Maybe it makes sense to go one step further and only allocate a max(size - offset) buffer? If I understand correctly, as it stands, we'd still allocate 128MiB if the upload is between two large buffers and ranges only hit a small part at the end? That said, I guess it's not a thing that happens commonly, so I'm not blocking this patch.