Class: File
A file.
Extends
BaseClient
Constructors
new File()
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
• parent?
• parent.ctx?: Context
• parent.queryTree?: QueryTree
[]
• _id?: FileID
• _contents?: string
• _digest?: string
• _export?: string
• _name?: string
• _size?: number
• _sync?: FileID
Returns
Overrides
BaseClient.constructor
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
• opts?: FileDigestOpts
Returns
Promise
<string
>
export()
export(
path
,opts
?):Promise
<string
>
Writes the file to a file path on the host.
Parameters
• 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
• arg
Returns
withName()
withName(
name
):File
Retrieves this file with its name set to the given name.
Parameters
• 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
• timestamp: number
Timestamp to set dir/files in.
Formatted in seconds following Unix epoch (e.g., 1672531199).