$.files
$.files
helper is the main module to interact with the Project’s File Store. It can instatiate new files, open files from descriptors and list the contents of the File Store.
$.files.open(path)
path
. If the file doesn’t exist, a new empty file is created.
$.files.openDescriptor(fileDescriptor)
File
from the JSON friendly description of a file. Useful for recreating a File
from a step export.
For example, export a File
as a step export which will render the File
as JSON:
File
instance from the step export friendly description:
$.files.dir(?path)
path
. By default it will list the files at the root directory.
Here’s an example of how to iterate over the files in the root directory and open them as File
instances:
$.files.dir()
will contain the following properties:
isDirectory()
- true
if this instance is a directory.isFile()
- true
if this instance is a file.path
- The path to the file.size
- The size of the file in bytes.modifiedAt
- The last modified at timestamp.File
$.files.open
or $.files.openDescriptor
, you’ll create a new instance of a File
with helper methods that give you more flexibility to perform programatic actions with the file.
File.toUrl()
File.toUrl()
will expire after 30 minutes.File.toFile(path)
/tmp
is writable in workflow environmentsOnly the /tmp
directory is writable in your workflow’s exection environment. So you must download your file to the /tmp
directory.File.toBuffer()
File.fromFile(localFilePath, ?contentType)
/tmp
local path. For example, if localFilePath
is given /tmp/recording.mp3
, it will upload that file to the current File Store File instance.
File.fromUrl(url)
url
to read from.
File.createWriteStream(?contentType, ?contentLength)
contentLength
argument is optional, however we do recommend passing it. Otherwise the entire file will need to be written to the local /tmp
before it can be uploaded to the File store.File.fromReadableStream(?contentType, ?contentLength)
ReadableStream
.
contentLength
argument is optional, however we do recommend passing it. Otherwise the entire file will need to be written to the local /tmp
before it can be uploaded to the File store.File.delete()