Skip to main content

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.

import abstra.files as files

# Create a test file
file_path = files.get_persistent_dir() / "test-file.txt"
file_path.write_text("This is a test file.")

# Generate a public link for the file
public_link = files.create_public_link(file_path)
print("Public Link:", public_link)
danger

Files made public will be unprotected and can be accessed from the web by anyone with the link.

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.

from abstra.files import get_public_dir

# Get the public directory path
public = get_public_dir()

# Create a simple text file that is publicly accessible
public_file = public / "public-note.txt"
public_file.write_text("This file is accessible to everyone.")

print(f"Public file created at: {public_file}")