github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/website/content/docs/job-specification/hcl2/functions/file/filebase64.mdx (about)

     1  ---
     2  layout: docs
     3  page_title: filebase64 - Functions - Configuration Language
     4  description: |-
     5    The filebase64 function reads the contents of the file at the given path and
     6    returns them as a base64-encoded string.
     7  ---
     8  
     9  # `filebase64` Function
    10  
    11  `filebase64` reads the contents of a file at the given path and returns them as
    12  a base64-encoded string.
    13  
    14  ```hcl
    15  filebase64(path)
    16  ```
    17  
    18  The result is a Base64 representation of the raw bytes in the given file.
    19  
    20  Nomad uses the "standard" Base64 alphabet as defined in
    21  [RFC 4648 section 4](https://tools.ietf.org/html/rfc4648#section-4).
    22  
    23  ## Examples
    24  
    25  ```
    26  > filebase64("${path.module}/hello.txt")
    27  SGVsbG8gV29ybGQ=
    28  ```
    29  
    30  ## Related Functions
    31  
    32  * [`file`](/docs/job-specification/hcl2/functions/file/file) also reads the contents of a given file,
    33    but interprets the data as UTF-8 text and returns the result directly
    34    as a string, without any further encoding.
    35  * [`base64decode`](/docs/job-specification/hcl2/functions/encoding/base64decode) can decode a
    36    Base64 string representing bytes in UTF-8, but in practice `base64decode(filebase64(...))`
    37    is equivalent to the shorter expression `file(...)`.