WebRADDocumentationExplore WebRAD ↗
WEBRAD / TECHNICAL REFERENCE

File Upload

Select a file and upload it to RestGO Storage.

WebFileUploadNonvisualNonvisual5 events

Quick start

Add FileUpload1 in the Designer. Use the example in a page method.

FileUpload1 · event
// Run from a user click.
const selection = await FileUpload1.OpenFile();
if (!selection) return;
try {
  const uploaded = await FileUpload1.SendToRestGO({ isPublic: false });
  Message(uploaded.id);
} catch (error) {
  Message(error instanceof Error ? error.message : String(error));
}
  • Configure accept and isPublic in the Inspector.
  • Call OpenFile() from a click; cancellation returns null. selectedFile provides the chosen File.
  • SendToRestGO() requires configured integration and a user session. Clear() clears the selection.
  • OnChange receives the selection; OnProgress receives progress; OnSuccess, OnError, and OnComplete track the upload.
  • Private files require authenticated downloads; generating a URL does not change isPublic.

Inspector properties

Component options and defaults. Fields without runtime access are configured in the Inspector.

Property / sourceType and optionsDefaultRuntime access
nameName · Identitystring—name
acceptAccepted file types · BehaviorNative file chooser filter, such as image/* or .pdf,.txt. Empty accepts all file types.string""accept
enabledEnabled · Behaviorbooleantrueenabled
isPublicPublic file · StorageDefault visibility when uploading. Private files require authorized access; upload options can override this value.booleanfalseisPublic

API in code

MemberSignatureAccess
acceptaccept: string;Read and write
isPublicisPublic: boolean;Read and write
enabledenabled: boolean;Read and write
selectedFilereadonly selectedFile: File | null;Read-only
selectionreadonly selection: WebFileUploadSelection | null;Read-only
fileNamereadonly fileName: string;Read-only
uploadingreadonly uploading: boolean;Read-only
progressreadonly progress: number | null;Read-only
resultreadonly result: WebFileUploadResult | null;Read-only
lastErrorreadonly lastError: Error | null;Read-only
onChangeset onChange(handler: WebComponentEventHandler<this> | null);Read and write
onSuccessset onSuccess(handler: WebComponentEventHandler<this> | null);Read and write
onErrorset onError(handler: WebComponentEventHandler<this> | null);Read and write
onCompleteset onComplete(handler: WebComponentEventHandler<this> | null);Read and write
onProgressset onProgress(handler: WebComponentEventHandler<this> | null);Read and write

OpenFile

method
OpenFile(): Promise<WebFileUploadSelection | null>;
Example
FileUpload1.OpenFile
await FileUpload1.OpenFile();

SendToRestGO

method
SendToRestGO(options?: WebFileUploadOptions): Promise<WebFileUploadResult>;
Example
FileUpload1.SendToRestGO
await FileUpload1.SendToRestGO({ isPublic: false });

Clear

method
Clear(): void;
Example
FileUpload1.Clear
FileUpload1.Clear();
Inherited members (5)
MemberSignatureAccess
idreadonly id: string;Read-only
namereadonly name: string;Read-only

bindEvent

method
bindEvent(eventName: string, handler: WebComponentEventHandler<this> | null): () => void;

emit

method
emit(eventName: string, detail?: unknown): boolean;

dispose

method
dispose(): void;

Events

Link methods in Interaction. How to use events.

OnChange

WebFileUploadChangeEventDetail in event.detail

Signature and example
Interaction → OnChange
import type { WebFileUpload, WebFileUploadChangeEventDetail } from '@webrad/runtime';
// Copy this method into the page class and link it in Interaction.
class Example {
  public async FileUpload1Change(
    sender: WebFileUpload,
    event: CustomEvent<WebFileUploadChangeEventDetail>,
  ): Promise<void> {
    console.log(event.detail);
  }
}

OnSuccess

WebFileUploadResult in event.detail · id, downloadUrl, url, isPublic

Signature and example
Interaction → OnSuccess
import type { WebFileUpload, WebFileUploadResult } from '@webrad/runtime';
// Copy this method into the page class and link it in Interaction.
class Example {
  public async FileUpload1Success(
    sender: WebFileUpload,
    event: CustomEvent<WebFileUploadResult>,
  ): Promise<void> {
    console.log(event.detail);
    const { id, downloadUrl, url, isPublic } = event.detail;
    console.log(id, downloadUrl, url, isPublic);
  }
}

OnProgress

WebFileUploadProgressEventDetail in event.detail · percentage, loaded, total, lengthComputable

Signature and example
Interaction → OnProgress
import type { WebFileUpload, WebFileUploadProgressEventDetail } from '@webrad/runtime';
// Copy this method into the page class and link it in Interaction.
class Example {
  public async FileUpload1Progress(
    sender: WebFileUpload,
    event: CustomEvent<WebFileUploadProgressEventDetail>,
  ): Promise<void> {
    console.log(event.detail);
    const { percentage, loaded, total, lengthComputable } = event.detail;
    console.log(percentage, loaded, total, lengthComputable);
  }
}

OnError

Error in event.detail

Signature and example
Interaction → OnError
import type { WebFileUpload } from '@webrad/runtime';
// Copy this method into the page class and link it in Interaction.
class Example {
  public async FileUpload1Error(
    sender: WebFileUpload,
    event: CustomEvent<Error>,
  ): Promise<void> {
    Message(event.detail.message);
  }
}

OnComplete

WebFileUploadCompleteEventDetail in event.detail · result, error

Signature and example
Interaction → OnComplete
import type { WebFileUpload, WebFileUploadCompleteEventDetail } from '@webrad/runtime';
// Copy this method into the page class and link it in Interaction.
class Example {
  public async FileUpload1Complete(
    sender: WebFileUpload,
    event: CustomEvent<WebFileUploadCompleteEventDetail>,
  ): Promise<void> {
    console.log(event.detail);
    const { result, error } = event.detail;
    console.log(result, error);
  }
}
WebRAD · Atentor · Read in Markdown
Source code: 6a562bda75a0 (with local changes) · November 7, 2026

Search documentation

Type to search APIs, components, and events.