You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, Could you please guide me how to extract base64 image from multipart.
In My code is below uploadToCloud function is responsible to upload files in cloud. It needs one variable mainly from multipart i.e base64 image. Now I am passing just passing key, imageType because I could not extract base64 image from field.file.
I am looking forward to get replies against my below queries:-
1.If I could read the buffer from field.file then I could encode it to base64. Could you tell me I could read the buffer.
2.How can I reproduce the error FILES_LIMIT_REACHED. Not mentioned in docs.
3. What is the advantage of multipart over normal method where hyper-express router receives a base64 image string as body from the client. On the other hand, in multipart I am sending the image from client as formdata.
let image_file;
let image_type;
try {
await request.multipart(async (field) => {
if (field.file && field.mime_type.startsWith('image/')) {
image_file = field.file.name
image_type = field.mime_type
//passing only jpeg, jpg & png type image
if (field.mime_type === 'image/jpeg' || field.mime_type === 'image/jpg' || field.mime_type === 'image/png') {
await field.write(image_file)
}
}
})
} catch (error) {
console.log(error);
if (typeof error === 'FILES_LIMIT_REACHED') {
return response.status(403).send('You sent too many files! Try again.')
} else {
return response.status(500).send('Oops! An uncaught error occured on our end.')
}
}
if (image_file) {
const { file } = await uploadToCloud({ key: image_file, imageType: image_type })
console.log(file);
return response.send("Successfully uploaded")
} else {
return response.status(400).send('No profile image was received. Please try again.');
}
The text was updated successfully, but these errors were encountered:
Hello, Could you please guide me how to extract base64 image from multipart.
In My code is below
uploadToCloud
function is responsible to upload files in cloud. It needs one variable mainly from multipart i.e base64 image. Now I am passing just passingkey, imageType
because I could not extract base64 image fromfield.file
.I am looking forward to get replies against my below queries:-
1.If I could read the buffer from
field.file
then I could encode it to base64. Could you tell me I could read the buffer.2.How can I reproduce the error FILES_LIMIT_REACHED. Not mentioned in docs.
3. What is the advantage of multipart over normal method where hyper-express router receives a base64 image string as body from the client. On the other hand, in multipart I am sending the image from client as formdata.
The text was updated successfully, but these errors were encountered: