Skip to main content
You may want to save data produced by your tasks. Beam provides an abstraction called Output, which allows you to save files or directories and generate public URLs to access them.

Saving Files

To save an Output, you can write any filetype to Beam’s /tmp directory. Here’s what your code might look like:

Directories

You can also create public URLs for directories, by passing in a directory path:

PIL Images

If your app uses PIL, Output includes a wrapper around PIL to simplify the process of generating a public URL for the PIL image file:
Here’s a full example:
When you run this function, it will return a pre-signed URL to the image:

Generating Public URLs

Your app might return files from the API, such as images or MP3s. You can use Output to generate a public URL to access the content.

Expiring Public URLs

You can pass an optional expires parameter to output.public_url to control how long to persist the file before it is deleted.
By default, public URLs are automatically deleted after 1 hour.