Buffered video upload not working
Estou utilizando Next JS para criação de um app, portanto, a única forma que consegui fazer uma comunicação de arquivos foi através de arquivos de buffer.
No caso das imagens, tudo funciona sem maiores problemas
Mas quando vou tentar fazer o uplaod de algum vídeo, eu recebo a seguinte mensagem:
{ message: 'Invalid image file', name: 'Error', http_code: 400 }
Follow the code
export const uploadBuffer = async (fileBuffer) => {
const cloudinaryService = cloudinary.v2
cloudinaryService.config({
cloud_name:process.env.CLOUDINARY_CLOUD_NAME,
api_key:process.env.CLOUDINARY_API_KEY,
api_secret:process.env.CLOUDINARY_API_SECRET,
})
const uploadFromBuffer = (buffer) => {
return new Promise((resolve, reject) => {
const config = { folder:'secrety' }
const stream = cloudinaryService.uploader.upload_stream(config, (error, result) => {
if (result) resolve(result)
else reject(error)
})
streamifier.createReadStream(buffer).pipe(stream)
})
}
const result = await uploadFromBuffer(fileBuffer)
return result
}
0
-
Hi Gabriel,
The default resource_type when sending the upload request is 'image' and you may need to set this parameter to 'video' as part of your code:
const config = {folder: 'secrety', resource_type: 'video'}Thanks to help to try this setting and kindly let me know the result if it works.
Best regards,
Eric
0
Post is closed for comments.
Comments
1 comment