๐๏ธWorking with Storage Files
How to prompt while working with Databutton's inbuilt storage
Last updated
How to prompt while working with Databutton's inbuilt storage
Last updated
The in-built Databutton storage supports various file types, such as text, CSV, and binary files. This storage is very useful for testing purposes, such as reading or writing files and testing endpoints.
We recommend using this storage for testing or small-scale applications. For scalable, production-level apps, consider alternatives like Firebase or Supabase. We have a mini tutorial on how to integrate Firebase.
How to upload files
Go to the Storage section ( left hand side of the workspace )
Click "Add File."
Upload / Drag & Drop the desired file from your computer
Fetch using Databutton's SDK: db.storage.binary.get()
or db.storage.text.get()
Read or perform operations using external Python libraries
Yes!
Databutton allows you to reference your files easily using the hashtag (#) symbol.
Selecting a specific file with an additional prompt enables Databutton to work its magic.
Databutton uses its own Python SDK to read files. It figures out the file type and necessary methods to assist users in building the endpoint efficiently.
Once the file is retrieved from storage, the downstream process can be managed smoothly based on the backend's final goal.
Here's an example of Databutton handling a PDF file using the db.storage.binary.get()
method. Next, Databutton uses an external Python library (PyMuPDF) to read the content of the PDF.
You will find the entire use case here.
Note: Soon, we will support working with image files. For the time being, follow the workaround here.
Databutton inbuilt storage also works fine with binary files like .mp3 or wav. You can find working with such files here.
Using hastags to refer specific files
Prompting Databutton to do what after the file is fetched.