How to only save file url when uploading to supabase
I'm following the example https://refine.dev/docs/advanced-tutorials/data-provider/supabase/#adding-a-create-page to implement file upload to supabase from antd. I'm trying to modify the code to only upload a single pdf file and save only the url in the supabase table.
Right now it is saving the whole file details in an array in the table column like
[{"uid":"rc-upload-1681232417825-10","name":"abcd.pdf","url":"https://abcd.supabase.co/storage/v1/object/public/agreements/public/abcd.pdf","type":"application/pdf","size":866584,"percent":100,"status":"done"}]
Supabase | refine
Introduction
10 Replies
Hi @ahnaf1022. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
To modify the code to upload a single PDF file and save only the URL in the Supabase table, you can make the following changes:
1. Set the
multiple
prop of the Upload.Dragger
component to false
to allow only a single file upload.
2. Modify the normalizeFile
function to return only the URL of the uploaded file instead of the whole file details.
Here's the modified code snippet from the Adding a Create page (https://refine.dev/docs/advanced-tutorials/data-provider/supabase#adding-a-create-page) example:
Supabase | refine
Introduction
This code will ensure that only a single PDF file can be uploaded, and only the URL of the uploaded file will be saved in the Supabase table.
----------------------
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon:
----------------------<@543682490951532554> kapa.ai is still learning and improving, please let us how it did by reacting below
plain-purple•2y ago
Now it is not saving anything to the table @kapa.ai
Let me check the knowledge base for you again. One moment! :books:
----------------------
Apologies for the confusion. I made a mistake in the
normalize
prop. It should be a function, not an object. Here's the corrected code snippet:
This should now save the URL of the uploaded PDF file to the Supabase table.
----------------------
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon:
----------------------<@543682490951532554> kapa.ai is still learning and improving, please let us how it did by reacting below
plain-purple•2y ago
That is the same code @kapa.ai
Let me check the knowledge base for you again. One moment! :books:
----------------------
Apologies for the confusion earlier. I made a mistake in my response. Here's the corrected code snippet:
This code snippet should now save the URL of the uploaded PDF file to the Supabase table. The key changes are setting
multiple
to false
and updating the normalize
prop to return only the URL of the uploaded file.
----------------------
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon:
----------------------<@543682490951532554> kapa.ai is still learning and improving, please let us how it did by reacting below