feat(editor): ✨ Add file upload input
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
import imageCompression from 'browser-image-compression'
|
||||
import { Parser } from 'htmlparser2'
|
||||
import { Block, Typebot } from 'models'
|
||||
import { sendRequest } from 'utils'
|
||||
|
||||
export const fetcher = async (input: RequestInfo, init?: RequestInit) => {
|
||||
const res = await fetch(input, init)
|
||||
@ -37,26 +36,6 @@ export const toKebabCase = (value: string) => {
|
||||
return matched.map((x) => x.toLowerCase()).join('-')
|
||||
}
|
||||
|
||||
export const uploadFile = async (file: File, filePath: string) => {
|
||||
const { data } = await sendRequest<{ presignedUrl: string }>(
|
||||
`/api/storage/upload-url?filePath=${encodeURIComponent(filePath)}`
|
||||
)
|
||||
|
||||
if (!data?.presignedUrl)
|
||||
return {
|
||||
url: null,
|
||||
}
|
||||
|
||||
await fetch(data.presignedUrl, {
|
||||
method: 'PUT',
|
||||
body: file,
|
||||
})
|
||||
|
||||
return {
|
||||
url: data.presignedUrl.split('?')[0],
|
||||
}
|
||||
}
|
||||
|
||||
export const compressFile = async (file: File) => {
|
||||
const options = {
|
||||
maxSizeMB: 0.5,
|
||||
|
Reference in New Issue
Block a user