Close
    logoCloudomation Docs

    File Handling with Cloudomation

    Cloudomation offers several options for working with files and file systems. This article describes the file handling functionality available to you on the Cloudomation platform, which allows you to work with files without needing a separate environment (e.g. a remote server) on which your file operations happen.

    The system.file Function

    The file function allows you to create file objects. Arguments:

    • name – string. The name of the file. If it doesn’t exist, it will be created.

    Note: file contents will be overwritten without warning if a file of the same name already exists.

    Returns:

    • The file object

    Example:

    import flow_api
    def handler(system: flow_api.System, this: flow_api.Execution):
    # create a file object
    file_object = system.file('myfile.txt')
    # write to the file
    file_object.save(text='saving some text')
    # read from the file
    text = file_object.get('content')
    this.log(text=text)
    return this.success('all done')

    The system.files Function

    The system.files function lists all files in a given directory.

    files = system.files(dir='flows', glob='**/*.py')

    Arguments:

    • **filters – dictionary. Filters to limit the search results.

    Returns:

    • An iterator over all matched files which generates File objects.

    Example:

    import flow_api
    def handler(system: flow_api.System, this: flow_api.Execution):
    # list all files on the Cloudomation platform
    all_files = system.files()
    for file in all_files:
    this.log(file)
    # List only *.zip files
    zip_files = system.files(filter={
    'field': 'name',
    'op': 'like',
    'value': '%.zip',
    })
    for zip_file in zip_files:
    this.log(zip_file)
    return this.success('all done')
    Knowledge Base — Previous
    Executions
    Next — Knowledge Base
    Flow Scripts