Is there a way to hide csv files on Spaces to prevent users from being able to download them? I’m aware you can add secrets but that doesn’t seem to cover files?
Hi @bradley6597, here’s a quick trick to get protected files on a public Space
- Create a new dataset/model
- Use the
huggingface_hub
library to clone the dataset/model on the path you’re running the script from - Dont forget to add the secret
HUGGING_FACE_HUB_TOKEN
to your Space secrets soRepository
can authenticatetoken=True
, you can also pass the token e.gtoken=os.environ["HUB_TOKEN"]
example
from huggingface_hub import Repository
repo = Repository(
local_dir="secret-csvs",
repo_type="dataset",
clone_from="radames/secret-csvs",
token=True
)
repo.git_pull()
Now you can read you files from the secret-csvs
folder
Thanks @radames!
I ended up following the same principles and used this code instead
from datasets import load_dataset
from huggingface_hub import login
login(token = os.environ['HUB_TOKEN'])
dataset = load_dataset("hugging/face/path")
1 Like