download / grab PDF from supabase storage and send it to an API
Hi there,
i have a supabase trigger on inserts. this trigger gives back a pdf path and id.
now i will send the id and binary pdf file to an API. How i should do this?
{
"schema": "public",
"type": "INSERT",
"old_record": null,
"record": {
"branch_name": "Gastronomie",
"pdf_name": "https://coodsldfgelifogiqfdd.supabase.co/storage/v1/object/public/analyses_bucket/pdf/1727406193189000.pdf",
"company": "wird ausgelesen..",
"id": 1210,
"status": "wird erstellt..",
"owner_uuid": "dac193c1-1d68-4cc1-a75f-4f19b970c22b",
"created_at": "2024-09-27T03:03:15.825172+00:00"
},
"table": "analyses"
}
3 Replies
AI Support Bot Information
<@1237643762801315881> you can react on the relevant answer (message) with a ✅ in this thread when you think it has been solved, by the bot or by a human!
Anyone can react on this message with a ❌ if the GPT bot is unhelpful or hallucinating answers.
Please note: Team members will review and answer the questions on best efforts basis.
AI Response
To achieve your goal of sending the ID and binary PDF file to an API using a Supabase trigger, you can follow these general steps:
1. Setup Supabase Trigger: Ensure that your trigger is correctly set to capture the INSERT events.
2. Download the PDF: Use the URL provided in the Supabase record to download the PDF file.
3. Send the Data to API: Utilize an HTTP request to send the ID and the PDF file to the desired API.
Here is a step-by-step outline in more detail:
1. Supabase Trigger Setup
Configure your trigger to execute a function upon an INSERT event. This function will handle the download and subsequent API request.
2. Download the PDF
The function can download the PDF from the given URL. Here is a rough outline:
- Extract the
pdf_name
(URL) and id
from the inserted record.
- Utilize a library (like requests
in Python or similar in other languages) to download the PDF.
3. Send the Data to API
Lastly, send the ID and the binary PDF file to the API:
- Construct a multipart/form-data payload containing the ID and the binary PDF.
- Send an HTTP POST request to your API endpoint.
Example (Python)
Make sure to replace placeholder values like your_supabase_url
, your_supabase_key
, and your_api_endpoint
with actual values. Adapt the code as necessary depending on the language and framework you are using.
For further reading and tutorials on building workflows involving Supabase triggers, check the BuildShip documentation:
- BuildShip Supabase Trigger【4:7†source】.
- General Workflow Tutorial【4:7†source】.
If you need any specific help with BuildShip configurations, don't hesitate to send a support request via your BuildShip Dashboard.
BuildShip AI Support
how to implement the python code into a node?