Sid | R2
03/15/2023, 2:42 AMvelek
03/15/2023, 2:43 AMSid | R2
03/15/2023, 2:43 AMBrame
03/15/2023, 2:44 AMBrame
03/15/2023, 2:44 AMErisa | Support Engineer
03/15/2023, 2:45 AMBrame
03/15/2023, 2:47 AMGNAS
03/15/2023, 3:25 AMGNAS
03/15/2023, 3:25 AMKarew
03/15/2023, 3:25 AMGNAS
03/15/2023, 3:28 AMvelek
03/15/2023, 5:55 AMzegevlier
03/15/2023, 6:54 AMtheompm
03/15/2023, 6:54 AMtheompm
03/15/2023, 6:56 AMtheompm
03/15/2023, 6:57 AMEli
03/15/2023, 11:00 AMexport const generateURL = async (fileType: string, fileSize: number, config: Config) => {
const allowed_file_size = 5
if (Number(fileSize) / (1024 * 1024) > allowed_file_size) {
throw Error('File too large')
}
const allowed_file_types = ['image/png', 'image/jpg', 'image/jpeg']
if (!allowed_file_types.includes(fileType)) {
throw Error(`File type not allowed. Allowed types are: ${allowed_file_types.join(', ')}.`)
}
const r2 = new AwsClient({
accessKeyId: config.r2.accessKey,
secretAccessKey: config.r2.secretKey
})
const fileName = `${nanoid(6)}.${fileType.split('/')[1]}`
const url =
`https://${config.r2.bucketName}.${config.r2.accountId}.r2.cloudflarestorage.com` +
'/profile' +
`/${fileName}` +
'?X-Amz-Expires=3600'
const signed = await r2.sign(url, {
aws: { signQuery: true },
headers: {
'Content-Type': fileType,
'Content-Length': `${fileSize}`
},
method: 'PUT'
})
return { fileName, url: signed.url }
}
Sid | R2
03/15/2023, 11:58 AMtheompm
03/15/2023, 12:02 PMSkye
03/15/2023, 12:03 PM/
to serve /index.html
?theompm
03/15/2023, 12:04 PMSkye
03/15/2023, 12:04 PMSkye
03/15/2023, 12:04 PMtheompm
03/15/2023, 12:06 PMxokaido
03/15/2023, 12:13 PMmorpig
03/15/2023, 12:31 PMmorpig
03/15/2023, 12:32 PMget: Client Disconnect (10054)
on my workers log, is it related with R2? i have r2 get + put ops, but idk what that error message relates to.nikitasius
03/15/2023, 2:58 PMSkye
03/15/2023, 2:59 PMnikitasius
03/15/2023, 3:01 PM