Table of Contents

Class FileUploadField

Namespace
AbanoubNassem.Trinity.Fields
Assembly
AbanoubNassem.Trinity.dll

Represents a file upload field that can be added to a form.

public class FileUploadField : CanUploadField<FileUploadField>, ITrinityField, IFormComponent, ICanUploadField, ITrinityComponent
Inheritance
FileUploadField
Implements
Inherited Members

Constructors

FileUploadField(string)

public FileUploadField(string columnName)

Parameters

columnName string

Properties

AllowImageTransform

Gets or sets a value indicating whether image transform is allowed.

public bool AllowImageTransform { get; protected set; }

Property Value

bool

AllowReorder

Gets or sets a value indicating whether the user is allowed to reorder the uploaded files.

public bool AllowReorder { get; protected set; }

Property Value

bool

AutoUploads

Gets or sets a value indicating whether uploaded files are automatically uploaded to the server.

public bool AutoUploads { get; protected set; }

Property Value

bool

ButtonProcessItemPosition

Gets or sets the position of the "process" button in the file upload field.

public string? ButtonProcessItemPosition { get; protected set; }

Property Value

string

ButtonRemoveItemPosition

Gets or sets the position of the "remove" button in the file upload field.

public string? ButtonRemoveItemPosition { get; protected set; }

Property Value

string

CanDownload

Gets or sets a value indicating whether the file can be downloaded.

public bool CanDownload { get; protected set; }

Property Value

bool

CanPreview

Gets or sets a value indicating whether the file can be previewed.

public bool CanPreview { get; protected set; }

Property Value

bool

ComponentName

The component name in the front-end side.

public override string ComponentName { get; }

Property Value

string

ExtraUploadValidation

Gets or sets the extra upload validation function.

protected Func<IFormFile, string?>? ExtraUploadValidation { get; set; }

Property Value

Func<IFormFile, string>

Remarks

The function should return a string message if the validation fails, or null if it passes.

FileTypes

Gets or sets the file types that the user can select.

public string[]? FileTypes { get; protected set; }

Property Value

string[]

Icon

Gets or sets the icon for the file upload field.

public string Icon { get; protected set; }

Property Value

string

The default value is "pi pi-image".

ImageCropAspectRatio

Gets or sets the aspect ratio of the image crop.

public string? ImageCropAspectRatio { get; protected set; }

Property Value

string

ImagePreviewHeight

Gets or sets the height of the image preview.

public int? ImagePreviewHeight { get; protected set; }

Property Value

int?

ImageResizeMode

Gets or sets the mode used for image resizing.

public string? ImageResizeMode { get; protected set; }

Property Value

string

ImageResizeTargetHeight

Gets or sets the height of the target image after resize.

public int? ImageResizeTargetHeight { get; protected set; }

Property Value

int?

ImageResizeTargetWidth

Gets or sets the width of the target image after resize.

public int? ImageResizeTargetWidth { get; protected set; }

Property Value

int?

ImageResizeUpscale

Gets or sets a value indicating whether to upscale the image during resizing.

public bool? ImageResizeUpscale { get; protected set; }

Property Value

bool?

ItemInsertLocation

Gets or sets the location where the item will be inserted.

public string? ItemInsertLocation { get; protected set; }

Property Value

string

LoadIndicatorPosition

Gets or sets the position of the load indicator element.

public string? LoadIndicatorPosition { get; protected set; }

Property Value

string

MaxFileSize

Gets or sets the maximum file size that the user can upload.

public string? MaxFileSize { get; protected set; }

Property Value

string

MaximumFileSize

Gets or sets the maximum file size that the user can upload.

public long? MaximumFileSize { get; protected set; }

Property Value

long?

MinFileSize

Gets or sets the minimum file size that the user can upload.

public string? MinFileSize { get; protected set; }

Property Value

string

MinimumFileSize

Gets or sets the minimum file size that the user can upload.

public long? MinimumFileSize { get; protected set; }

Property Value

long?

Multiple

Gets or sets a value indicating whether multiple files can be uploaded at once.

public bool Multiple { get; protected set; }

Property Value

bool

true if multiple files can be uploaded; otherwise, false. The default value is false.

PanelAspectRatio

Gets or sets the aspect ratio of the panel element.

public string? PanelAspectRatio { get; protected set; }

Property Value

string

PanelLayout

Gets or sets the layout of the panel element.

public string? PanelLayout { get; protected set; }

Property Value

string

ProgressIndicatorPosition

Gets or sets the position of the progress indicator element.

public string? ProgressIndicatorPosition { get; protected set; }

Property Value

string

RemoveUploadedFileButtonPosition

Gets or sets the position of the "remove uploaded file" button in the file upload field.

public string? RemoveUploadedFileButtonPosition { get; protected set; }

Property Value

string

ShouldOrientImageFromExif

Gets or sets a value indicating whether the uploaded image should be oriented from EXIF data.

public bool ShouldOrientImageFromExif { get; protected set; }

Property Value

bool

Template

Gets or sets the template for the file upload field.

public string Template { get; protected set; }

Property Value

string

The default value is "basic".

UploadProgressIndicatorPosition

Gets or sets the position of the upload progress indicator element.

public string? UploadProgressIndicatorPosition { get; protected set; }

Property Value

string

Methods

Fill(ref Dictionary<string, object?>, IReadOnlyDictionary<string, object?>?)

Fills a form with data from a record for the field.

public override void Fill(ref Dictionary<string, object?> form, IReadOnlyDictionary<string, object?>? oldRecord = null)

Parameters

form Dictionary<string, object>

The form to fill.

oldRecord IReadOnlyDictionary<string, object>

SetAllowImageTransform(bool)

Sets a value indicating whether image transform is allowed.

public FileUploadField SetAllowImageTransform(bool allow = true)

Parameters

allow bool

The value to set.

Returns

FileUploadField

The current FileUploadField instance.

SetAllowReorder(bool)

Sets whether the user is allowed to reorder the uploaded files.

public FileUploadField SetAllowReorder(bool allowReorder = true)

Parameters

allowReorder bool

Whether the user is allowed to reorder the uploaded files.

Returns

FileUploadField

The FileUploadField instance.

SetAsImage()

Sets the accepted file types for the file upload field to images only.

public FileUploadField SetAsImage()

Returns

FileUploadField

The current instance of the FileUploadField class.

SetAsMultiple(bool)

Sets whether multiple files can be uploaded at once.

public FileUploadField SetAsMultiple(bool multiple = true)

Parameters

multiple bool

true to allow multiple files to be uploaded; otherwise, false.

Returns

FileUploadField

The FileUploadField instance.

SetAutoUploads(bool)

Sets whether uploaded files are automatically uploaded to the server.

public FileUploadField SetAutoUploads(bool auto = true)

Parameters

auto bool

Whether uploaded files are automatically uploaded to the server.

Returns

FileUploadField

The FileUploadField instance.

SetButtonProcessItemPosition(string)

Sets the position of the "process" button in the file upload field.

public FileUploadField SetButtonProcessItemPosition(string buttonProcessItemPosition)

Parameters

buttonProcessItemPosition string

The position of the "process" button.

Returns

FileUploadField

The current FileUploadField instance.

SetButtonRemoveItemPosition(string)

Sets the position of the "remove" button in the file upload field.

public FileUploadField SetButtonRemoveItemPosition(string buttonRemoveItemPosition)

Parameters

buttonRemoveItemPosition string

The position of the "remove" button.

Returns

FileUploadField

The current FileUploadField instance.

SetCanDownload(bool)

Sets a value indicating whether the file can be previewed.

public FileUploadField SetCanDownload(bool can = true)

Parameters

can bool

The value to set.

Returns

FileUploadField

The current FileUploadField instance.

SetCanPreview(bool)

Sets a value indicating whether the file can be previewed.

public FileUploadField SetCanPreview(bool auto = true)

Parameters

auto bool

The value to set.

Returns

FileUploadField

The current FileUploadField instance.

SetExtraUploadValidation(Func<IFormFile, string?>)

Sets the extra upload validation function for the file upload field.

public FileUploadField SetExtraUploadValidation(Func<IFormFile, string?> extraUploadValidation)

Parameters

extraUploadValidation Func<IFormFile, string>

The extra upload validation function to set.

Returns

FileUploadField

The current FileUploadField instance.

SetFileTypes(params string[])

Sets the file types that the user can select.

public FileUploadField SetFileTypes(params string[] acceptTypes)

Parameters

acceptTypes string[]

The file types that the user can select.

Returns

FileUploadField

The FileUploadField instance.

SetImageCropAspectRatio(string)

Sets the aspect ratio of the image crop.

public FileUploadField SetImageCropAspectRatio(string imageCropAspectRatio)

Parameters

imageCropAspectRatio string

The aspect ratio to set.

Returns

FileUploadField

The current FileUploadField instance.

SetImagePreviewHeight(int)

Sets the height of the image preview.

public FileUploadField SetImagePreviewHeight(int imagePreviewHeight)

Parameters

imagePreviewHeight int

The height of the image preview.

Returns

FileUploadField

The updated FileUploadField instance.

SetImageResizeMode(ImageResizeModeType)

Sets the mode used for image resizing.

public FileUploadField SetImageResizeMode(ImageResizeModeType mode)

Parameters

mode ImageResizeModeType

The mode used for image resizing.

Returns

FileUploadField

The updated FileUploadField instance.

SetImageResizeTargetHeight(int)

Sets the height of the target image after resize.

public FileUploadField SetImageResizeTargetHeight(int imageResizeTargetHeight)

Parameters

imageResizeTargetHeight int

The height of the target image after resize.

Returns

FileUploadField

The updated FileUploadField instance.

SetImageResizeTargetWidth(int)

Sets the width of the target image after resize.

public FileUploadField SetImageResizeTargetWidth(int imageResizeTargetWidth)

Parameters

imageResizeTargetWidth int

The width of the target image after resize.

Returns

FileUploadField

The updated FileUploadField instance.

SetImageResizeUpscale(bool)

Sets a value indicating whether to upscale the image during resizing.

public FileUploadField SetImageResizeUpscale(bool imageResizeUpscale = true)

Parameters

imageResizeUpscale bool

The value indicating whether to upscale the image during resizing.

Returns

FileUploadField

The updated FileUploadField instance.

SetItemInsertLocation(ItemInsertLocationType)

Sets the location where the item will be inserted.

public FileUploadField SetItemInsertLocation(ItemInsertLocationType itemInsertLocation)

Parameters

itemInsertLocation ItemInsertLocationType

The location where the item will be inserted.

Returns

FileUploadField

The updated FileUploadField instance.

SetLoadIndicatorPosition(string)

Sets the position of the load indicator element.

public FileUploadField SetLoadIndicatorPosition(string loadIndicatorPosition)

Parameters

loadIndicatorPosition string

The position of the load indicator element.

Returns

FileUploadField

The current instance of the FileUploadField class.

SetMaximumFileSize(long)

Sets the maximum file size that the user can upload.

public FileUploadField SetMaximumFileSize(long maxBytes)

Parameters

maxBytes long

The maximum file size that the user can upload.

Returns

FileUploadField

The FileUploadField instance.

SetMinimumFileSize(long)

Sets the minimum file size that the user can upload.

public FileUploadField SetMinimumFileSize(long minBytes)

Parameters

minBytes long

The minimum file size that the user can upload.

Returns

FileUploadField

The FileUploadField instance.

SetPanelAspectRatio(string)

Sets the aspect ratio of the panel element.

public FileUploadField SetPanelAspectRatio(string panelAspectRatio)

Parameters

panelAspectRatio string

The aspect ratio of the panel element.

Returns

FileUploadField

The current instance of the FileUploadField class.

SetPanelLayout(PanelLayoutType)

Sets the layout of the panel element.

public FileUploadField SetPanelLayout(PanelLayoutType panelLayout)

Parameters

panelLayout PanelLayoutType

The layout of the panel element.

Returns

FileUploadField

The current instance of the FileUploadField class.

SetProgressIndicatorPosition(string)

Sets the position of the progress indicator element.

public FileUploadField SetProgressIndicatorPosition(string progressIndicatorPosition)

Parameters

progressIndicatorPosition string

The position of the progress indicator element.

Returns

FileUploadField

The current instance of the FileUploadField class.

SetRemoveUploadedFileButtonPosition(string)

Sets the position of the "remove uploaded file" button in the file upload field.

public FileUploadField SetRemoveUploadedFileButtonPosition(string removeUploadedFileButtonPosition)

Parameters

removeUploadedFileButtonPosition string

The position of the "remove uploaded file" button.

Returns

FileUploadField

The current FileUploadField instance.

SetShouldOrientImageFromExif(bool)

Sets the value indicating whether the uploaded image should be oriented from EXIF data.

public FileUploadField SetShouldOrientImageFromExif(bool shouldOrientImageFromExif = true)

Parameters

shouldOrientImageFromExif bool

The value to set.

Returns

FileUploadField

The current FileUploadField instance.

SetUploadProgressIndicatorPosition(string)

Sets the position of the upload progress indicator element.

public FileUploadField SetUploadProgressIndicatorPosition(string uploadProgressIndicatorPosition)

Parameters

uploadProgressIndicatorPosition string

The position of the upload progress indicator element.

Returns

FileUploadField

The current instance of the FileUploadField class.

SetUploadTemplate(FileUploadTemplate, string)

Sets the template and icon for the file upload field.

public FileUploadField SetUploadTemplate(FileUploadTemplate template, string icon = "pi pi-image")

Parameters

template FileUploadTemplate

The template to set.

icon string

The icon to set. The default value is "pi pi-image".

Returns

FileUploadField

The FileUploadField instance.

Upload(IFormFile)

Uploads the specified file.

public override Task<string?> Upload(IFormFile file)

Parameters

file IFormFile

Returns

Task<string>

A task representing the asynchronous operation that returns the URL of the uploaded file.