Public Files
Making Files Public
Sometimes you need to share files with others, and Abstra makes it easy to create public links for your files. This allows you to share files without needing to send them directly.
In a published execution, files made public will be unprotected and can be accessed from the web by anyone with the link. Do not create public links for files that must remain private.
Testing Links in the Cloud Editor
create_public_link() returns a URL on the host of the environment where your code runs. A link generated in the cloud editor points to the project's preview host, not its published application. Preview files require an authenticated preview session; these links are not anonymous sharing links.
To validate an editor-generated link without bypassing authentication:
- Open your Page through the editor's preview to establish the preview session. Being signed in to the console alone does not authenticate the preview host.
- Follow the generated link from that preview, on the same origin. For a programmatic read, fetch the original URL from the preview document only when its origin matches the document's origin. A session established inside the preview panel may be separate from one in a new top-level tab; open the editor's full-screen preview when testing in a separate tab.
- Check the response status and file contents. A
401indicates a missing or expired preview session; a403can indicate a cross-origin request, not a missing file.
The current preview host uses preview-<project-id>. Older executions can produce web-editor-<project-id> links. Although the old host remains an alias, the two hosts are different origins: requests between them are refused, even with a valid session. Do not manually replace the host in a generated link or copy authentication tokens into it.
If newly generated links still use the old host, reopen the editor to trigger the worker update, then regenerate the links after it completes. The update is asynchronous and does not rewrite URLs already stored in a spreadsheet or report.
To share a report with people outside the editor, generate its links in a published execution. Successfully reading an editor link with your preview session does not validate anonymous access to the published application.
Listing Public Files
You can check the files that are publicly available by using the get_public_dir() function. This will return the path to the _public directory inside Files.