Remarks
Instances are returned byAssetContext.getAsset. Each method lazily
fetches the file from the engine’s virtual file system and returns the
content in the requested format.
All read methods throw NfFetchException when the underlying fetch
returns a non-OK response.
Example
Constructors
Constructor
new NfFile(Defined in: packages/common/src/common/file.ts:26path):NfFile
Parameters
path
string
Internal URL path used to fetch the file.
Returns
NfFile
Accessors
path
Get Signature
get path(): string
Defined in: packages/common/src/common/file.ts:33
Internal URL path used to fetch the file.
Returns
string
Methods
arrayBuffer()
arrayBuffer():Defined in: packages/common/src/common/file.ts:42 Fetch the file and return its content as anPromise<ArrayBuffer>
ArrayBuffer.
Returns
Promise<ArrayBuffer>
Throws
NfFetchException When the HTTP response is not OK.
blob()
blob():Defined in: packages/common/src/common/file.ts:52 Fetch the file and return its content as aPromise<Blob>
Blob.
Returns
Promise<Blob>
Throws
NfFetchException When the HTTP response is not OK.
bytes()
bytes():Defined in: packages/common/src/common/file.ts:62 Fetch the file and return its content as aPromise<Uint8Array<ArrayBuffer>>
Uint8Array.
Returns
Promise<Uint8Array<ArrayBuffer>>
Throws
NfFetchException When the HTTP response is not OK.
formData()
formData():Defined in: packages/common/src/common/file.ts:72 Fetch the file and return its content asPromise<FormData>
FormData.
Returns
Promise<FormData>
Throws
NfFetchException When the HTTP response is not OK.
json()
json():Defined in: packages/common/src/common/file.ts:82 Fetch the file, parse it as JSON, and return the result.Promise<any>
Returns
Promise<any>
Throws
NfFetchException When the HTTP response is not OK.
text()
text():Defined in: packages/common/src/common/file.ts:92 Fetch the file and return its content as a UTF-8 string.Promise<string>
Returns
Promise<string>
Throws
NfFetchException When the HTTP response is not OK.