2
0

feat(bot): ️ Add custom file upload size limit

This commit is contained in:
Baptiste Arnaud
2022-06-21 16:53:45 +02:00
parent 1931a5c9c0
commit ea765640cf
17 changed files with 141 additions and 44 deletions

View File

@ -193,6 +193,7 @@ export const generateId = (idDesiredLength: number): string => {
}
type UploadFileProps = {
basePath?: string
files: {
file: File
path: string
@ -202,6 +203,7 @@ type UploadFileProps = {
type UrlList = string[]
export const uploadFiles = async ({
basePath = '/api',
files,
onUploadProgress,
}: UploadFileProps): Promise<UrlList> => {
@ -209,9 +211,9 @@ export const uploadFiles = async ({
const { data } = await sendRequest<{
presignedUrl: { url: string; fields: any }
}>(
`/api/storage/upload-url?filePath=${encodeURIComponent(path)}&fileType=${
file.type
}`
`${basePath}/storage/upload-url?filePath=${encodeURIComponent(
path
)}&fileType=${file.type}`
)
if (!data?.presignedUrl) return null