Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


DownloadHandlerBuffer

A general-purpose DownloadHandler implementation which stores received data in a native byte buffer.
Read time 1 minuteLast updated 4 days ago

Definition

public sealed class DownloadHandlerBuffer : DownloadHandler, IDisposable

Remarks

This is a general-purpose DownloadHandler subclass. It stores received data in native memory. It preallocates a data buffer based on any received
Content-Length
header, but expands its buffer if the actual download size exceeds the value of the
Content-Length
header (or if a
Content-Length
header is not received).
Note: When accessing _data or _text on this subclass, a new byte array or string is allocated each time the property is accessed.

Examples

using UnityEngine;using UnityEngine.Networking;using System.Collections;public class MyBehaviour : MonoBehaviour { void Start() { StartCoroutine(GetText()); } IEnumerator GetText() { UnityWebRequest www = new UnityWebRequest("https://www.my-server.com"); www.downloadHandler = new DownloadHandlerBuffer(); yield return www.SendWebRequest(); if (www.result != UnityWebRequest.Result.Success) { Debug.Log(www.error); } else { // Show results as text Debug.Log(www.downloadHandler.text); // Or retrieve results as binary data byte[] results = www.downloadHandler.data; } }}

Constructors

Constructor

Description

DownloadHandlerBuffer()Default constructor.

Static Methods

Method

Description

GetContentReturns a copy of the native-memory buffer interpreted as a UTF8 string.

Inheritance