TypeScript SDK Reference
api/client.gen.File
A file.
Hierarchy
-
BaseClient
↳
File
Constructors
constructor
new File(parent?
, _id?
, _contents?
, _digest?
, _export?
, _name?
, _size?
, _sync?
): File
Constructor is used for internal usage only, do not create object from it.
Parameters
Name | Type |
---|---|
parent? | Object |
parent.ctx | Context |
parent.queryTree? | QueryTree [] |
_id? | FileID |
_contents? | string |
_digest? | string |
_export? | string |
_name? | string |
_size? | number |
_sync? | FileID |
Returns
Overrides
BaseClient.constructor
Properties
_contents
Private
Optional
Readonly
_contents: string
= undefined
_digest
Private
Optional
Readonly
_digest: string
= undefined
_export
Private
Optional
Readonly
_export: string
= undefined
_id
Private
Optional
Readonly
_id: FileID
= undefined
_name
Private
Optional
Readonly
_name: string
= undefined
_size
Private
Optional
Readonly
_size: number
= undefined
_sync
Private
Optional
Readonly
_sync: FileID
= undefined
Methods
contents
contents(): Promise
<string
>
Retrieves the contents of the file.
Returns
Promise
<string
>
digest
digest(opts?
): Promise
<string
>
Return the file's digest. The format of the digest is not guaranteed to be stable between releases of Dagger. It is guaranteed to be stable between invocations of the same Dagger engine.
Parameters
Name | Type |
---|---|
opts? | FileDigestOpts |
Returns
Promise
<string
>
export
export(path
, opts?
): Promise
<string
>
Writes the file to a file path on the host.
Parameters
Name | Type | Description |
---|---|---|
path | string | Location of the written directory (e.g., "output.txt"). |
opts? | FileExportOpts | - |
Returns
Promise
<string
>
id
id(): Promise
<FileID
>
A unique identifier for this File.
Returns
Promise
<FileID
>
name
name(): Promise
<string
>
Retrieves the name of the file.
Returns
Promise
<string
>
size
size(): Promise
<number
>
Retrieves the size of the file, in bytes.
Returns
Promise
<number
>
sync
sync(): Promise
<File
>
Force evaluation in the engine.
Returns
Promise
<File
>
with
with(arg
): File
Call the provided function with current File.
This is useful for reusability and readability by not breaking the calling chain.
Parameters
Name | Type |
---|---|
arg | (param : File ) => File |
Returns
withName
withName(name
): File
Retrieves this file with its name set to the given name.
Parameters
Name | Type | Description |
---|---|---|
name | string | Name to set file to. |
Returns
withTimestamps
withTimestamps(timestamp
): File
Retrieves this file with its created/modified timestamps set to the given time.
Parameters
Name | Type | Description |
---|---|---|
timestamp | number | Timestamp to set dir/files in. Formatted in seconds following Unix epoch (e.g., 1672531199). |