Class FileUploadField
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
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
AutoUploads
Gets or sets a value indicating whether uploaded files are automatically uploaded to the server.
public bool AutoUploads { get; protected set; }
Property Value
ButtonProcessItemPosition
Gets or sets the position of the "process" button in the file upload field.
public string? ButtonProcessItemPosition { get; protected set; }
Property Value
ButtonRemoveItemPosition
Gets or sets the position of the "remove" button in the file upload field.
public string? ButtonRemoveItemPosition { get; protected set; }
Property Value
CanDownload
Gets or sets a value indicating whether the file can be downloaded.
public bool CanDownload { get; protected set; }
Property Value
CanPreview
Gets or sets a value indicating whether the file can be previewed.
public bool CanPreview { get; protected set; }
Property Value
ComponentName
The component name in the front-end side.
public override string ComponentName { get; }
Property Value
ExtraUploadValidation
Gets or sets the extra upload validation function.
protected Func<IFormFile, string?>? ExtraUploadValidation { get; set; }
Property Value
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
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
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
LoadIndicatorPosition
Gets or sets the position of the load indicator element.
public string? LoadIndicatorPosition { get; protected set; }
Property Value
MaxFileSize
Gets or sets the maximum file size that the user can upload.
public string? MaxFileSize { get; protected set; }
Property Value
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
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 isfalse
.
PanelAspectRatio
Gets or sets the aspect ratio of the panel element.
public string? PanelAspectRatio { get; protected set; }
Property Value
PanelLayout
Gets or sets the layout of the panel element.
public string? PanelLayout { get; protected set; }
Property Value
ProgressIndicatorPosition
Gets or sets the position of the progress indicator element.
public string? ProgressIndicatorPosition { get; protected set; }
Property Value
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
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
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
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
boolThe 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
boolWhether 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
booltrue
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
boolWhether 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
stringThe 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
stringThe 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
boolThe 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
boolThe 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
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
stringThe 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
intThe 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
ImageResizeModeTypeThe 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
intThe 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
intThe 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
boolThe 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
ItemInsertLocationTypeThe 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
stringThe 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
longThe 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
longThe 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
stringThe 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
PanelLayoutTypeThe 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
stringThe 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
stringThe 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
boolThe 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
stringThe 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
FileUploadTemplateThe template to set.
icon
stringThe 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