Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


UploadHandlerFile

A specialized UploadHandler that reads data from a given file and sends raw bytes to the server as the request body.
Read time 1 minuteLast updated 4 days ago

Definition

public sealed class UploadHandlerFile : UploadHandler, IDisposable

Remarks

You can use it to send a large amount of data to the server with a low memory footprint.

Examples

using System.Collections;using UnityEngine;using UnityEngine.Networking;public class UHFileSample : MonoBehaviour{ void Start() { StartCoroutine(UploadFileData()); } IEnumerator UploadFileData() { using (var uwr = new UnityWebRequest("https://yourwebsite.com/upload", UnityWebRequest.kHttpVerbPUT)) { uwr.uploadHandler = new UploadHandlerFile("/path/to/file"); yield return uwr.SendWebRequest(); if (uwr.result != UnityWebRequest.Result.Success) Debug.LogError(uwr.error); else { // file data successfully sent } } }}

Constructors

Constructor

Description

UploadHandlerFile(System.String)Create a new upload handler to send data from the given file to the server.

Inheritance