Enable Video Upload
indigofa opened this issue · 6 comments
This library is awesome, thank you for making it.
I'm using image upload like in the code bellow and it's working fine, I would like to know is there a way I can do the same and enable Video Upload aswell
widgets = {
[
ImageBlockConfig({
options: {
upload_handler: handleUploadContentMediaHander,
},
}),
]
}
const handleUploadContentMediaHander = (file, imageBlock) => {
setLoadingContentMedia(true)
imageBlock.startLoader()
const ext = file.name.substr(file.name.lastIndexOf(".") + 1)
const filename = `${uuidv4()}.${ext}`
const getSignedUrl = async cb => {
const response = await Api.getImageUploadUrl(getToken(), [
{ key: filename },
])
cb(null, response)
}
const uploadMedia = async (storage, cb) => {
try {
await fetch(storage[0].url, {
method: "PUT",
body: file,
})
setLoadingContentMedia(false)
imageBlock.stopLoader()
cb(null, storage)
} catch (err) {
setLoadingContentMedia(false)
imageBlock.stopLoader()
cb(err)
}
}
const transformMediaContent = async (storage, cb) => {
const type = file.type.split("/")[0]
try {
const result = await Api.transformMedia(
getToken(),
type,
storage[0].key
)
cb(null, result)
} catch (err) {
cb(err)
}
}
Hi , you could take the image block as an starting point. In this case I would add a new block type to support video and make a different implementation. If you can make an fork and share your implementation I could help a bit more
Hi Michelson,
I will try to implement tonight and get back
Thank you
Maybe can make the same component accept images/*,videos/*
@michelson
@michelson I get this file as starting point image.js I want to create video uploader, my question is how can I allow to select video files ex mp4, right now I'm allowed to select only images extensions
thanks
@michelson can you please give me idea how can I solve this issue I'm having this is the video upload codesandbox I get image.js as a starting point, the problem I'm having is when I try to select the file I'm unable to select video files with extensions .mp4 or any other video extensions, it is allowed only image file.