1
//native
2
type Supabase = {
3
key: string
4
}
5
/**
6
* Updates project's storage config
7
*
8
*/
9
export async function main(
10
auth: Supabase,
11
ref: string,
12
body: {
13
fileSizeLimit?: number
14
features?: {
15
imageTransformation: { enabled: false | true }
16
s3Protocol: { enabled: false | true }
17
18
19
) {
20
const url = new URL(`https://api.supabase.com/v1/projects/${ref}/config/storage`)
21
22
const response = await fetch(url, {
23
method: 'PATCH',
24
headers: {
25
'Content-Type': 'application/json',
26
Authorization: 'Bearer ' + auth.key
27
},
28
body: JSON.stringify(body)
29
})
30
if (!response.ok) {
31
const text = await response.text()
32
throw new Error(`${response.status} ${text}`)
33
34
return await response.text()
35
36