magenta
05/25/2023, 2:24 PM/**
*
* @param url <string> - the Supabase URL string of the image to fetch
* @returns <string> - a URL object string that can be used in an <img src={getImageSm('someImage')}> tag
*
* TODO: string validation
* better return object error handling
*/
export const getPostImage = async (url: string) => {
const { data, error: downloadError } = await imageBucket('images').download(url, {
transform: {
width: 384
}
});
if (downloadError) {
throw downloadError;
}
return URL.createObjectURL(data);
};
garyaustin
05/25/2023, 2:53 PMmagenta
05/25/2023, 3:20 PMgaryaustin
05/25/2023, 4:10 PMmagenta
05/25/2023, 7:25 PMgaryaustin
05/25/2023, 7:29 PM