๐๏ธWorking with Storage Files
How to prompt while working with Databutton's inbuilt storage
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
What should be a typical workflow while working with storage files ?
Fetch using Databutton's SDK:
db.storage.binary.get()
ordb.storage.text.get()
Read or perform operations using external Python libraries
Can Databutton guide me to perform this workflow?
Yes!
How to prompt your files
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.
Text Files
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.
PDF / Binary Files
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.
Prompting tips to keep in mind ?
Using hastags to refer specific files
Prompting Databutton to do what after the file is fetched.
Last updated