You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I know this is already on the list. Adding an issue to discuss what to expose exactly. Something like the following could be pushed into the provider.
We'll likely want to offer a function to get a bucket name from a record/field/file.
Further the below uses public urls which is probably not ideal but alternatives might require a SignedImageField.
We also might want to offer the opportunity to remove previous files as new ones are uploaded.
Any thoughts on all this before I carry anything further?
exportconstdataProvider=withLifecycleCallbacks(supabaseDataProvider({instanceUrl: REACT_APP_SUPABASE_URL,apiKey: REACT_APP_SUPABASE_KEY,
supabaseClient,}),[{resource: "*",// Note * support is unreleased so we'll want to wait on thatbeforeSave: async(data: any,dataProvider: any)=>{constnewFiles=(awaitPromise.all(Object.keys(data).filter((key)=>data[key]?.rawFileinstanceofFile).map((key)=>[key,data[key]]).map(async([key,file]: any)=>{const{ data, error }=awaitsupabaseClient.storage.from("<bucket name>").upload(file.rawFile.name,file.rawFile)if(error)throwerrorconstpath=`${REACT_APP_SUPABASE_URL}/storage/v1/object/public/<bucket name>/${data?.path}`return{[key]: path}}))).reduce((acc,val)=>({ ...acc, ...val}),{})return{ ...data, ...newFiles}},},])
The text was updated successfully, but these errors were encountered:
Thank you so much for this suggestion, and for offering to work on this feature! 🙏
Further the below uses public urls which is probably not ideal but alternatives might require a SignedImageField.
True. Creating a SignedImageField component would certainly be a valid option. I guess it would take a supabaseClient prop?
Alternatively, we could also call supabase.storage.from('bucket').createSignedUrl('private-document.pdf', 3600) and directly return a time-limited URL.
In any case, for a first version of the implementation, it's OK to support only public URL for now IMO.
We also might want to offer the opportunity to remove previous files as new ones are uploaded.
It would be very nice indeed, but it would go even further than what we documented in the OSS docs and, again, for a first version, this is not a requirement IMHO.
Note * support is unreleased so we'll want to wait on that
* support is scheduled for RA v5 if I'm not mistaken, so it will probably take some more weeks to be available. In the docs we can simply give examples with resource: "posts" and people will probably figure out how to generalize that when the * feature is available.
Now a question of my own: what API do you have in mind for that feature? Something like this?
I know this is already on the list. Adding an issue to discuss what to expose exactly. Something like the following could be pushed into the provider.
We'll likely want to offer a function to get a bucket name from a record/field/file.
Further the below uses public urls which is probably not ideal but alternatives might require a SignedImageField.
We also might want to offer the opportunity to remove previous files as new ones are uploaded.
Any thoughts on all this before I carry anything further?
The text was updated successfully, but these errors were encountered: