Table of Contents

Class FileParameter

Namespace
RestSharp
Assembly
RestSharp.dll

Container for files to be uploaded with requests

public record FileParameter : IEquatable<FileParameter>
Inheritance
FileParameter
Implements
Inherited Members

Constructors

FileParameter(FileParameter)

protected FileParameter(FileParameter original)

Parameters

original FileParameter

Properties

ContentType

MIME content type of file

public string? ContentType { get; }

Property Value

string

EqualityContract

protected virtual Type EqualityContract { get; }

Property Value

Type

FileName

Name of the file to use when uploading

public string FileName { get; }

Property Value

string

GetFile

Provides raw data for file

public Func<Stream> GetFile { get; }

Property Value

Func<Stream>

Name

Name of the parameter

public string Name { get; }

Property Value

string

Options

public FileParameterOptions Options { get; }

Property Value

FileParameterOptions

Methods

Create(string, byte[], string, string?, FileParameterOptions?)

Creates a file parameter from an array of bytes.

public static FileParameter Create(string name, byte[] data, string filename, string? contentType = null, FileParameterOptions? options = null)

Parameters

name string

The parameter name to use in the request.

data byte[]

The data to use as the file's contents.

filename string

The filename to use in the request.

contentType string

The content type to use in the request.

options FileParameterOptions

File parameter options

Returns

FileParameter

The FileParameter

Create(string, Func<Stream>, string, string?, FileParameterOptions?)

Creates a file parameter from an array of bytes.

public static FileParameter Create(string name, Func<Stream> getFile, string fileName, string? contentType = null, FileParameterOptions? options = null)

Parameters

name string

The parameter name to use in the request.

getFile Func<Stream>

Delegate that will be called with the request stream so you can write to it..

fileName string

The filename to use in the request.

contentType string

Optional: parameter content type, default is "application/g-zip"

options FileParameterOptions

File parameter options

Returns

FileParameter

The FileParameter using the default content type.

Equals(FileParameter?)

public virtual bool Equals(FileParameter? other)

Parameters

other FileParameter

Returns

bool

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

FromFile(string, string?, string?, FileParameterOptions?)

public static FileParameter FromFile(string fullPath, string? name = null, string? contentType = null, FileParameterOptions? options = null)

Parameters

fullPath string
name string
contentType string
options FileParameterOptions

Returns

FileParameter

GetHashCode()

public override int GetHashCode()

Returns

int

PrintMembers(StringBuilder)

protected virtual bool PrintMembers(StringBuilder builder)

Parameters

builder StringBuilder

Returns

bool

ToString()

public override string ToString()

Returns

string

Operators

operator ==(FileParameter?, FileParameter?)

public static bool operator ==(FileParameter? left, FileParameter? right)

Parameters

left FileParameter
right FileParameter

Returns

bool

operator !=(FileParameter?, FileParameter?)

public static bool operator !=(FileParameter? left, FileParameter? right)

Parameters

left FileParameter
right FileParameter

Returns

bool