Hi,
I'm trying to upload images to server.
The request works well, but the body are buffered.
What can i do to get real data from body buffered?
I tried Buffer.from(req.body, 'utf8'), but it wrong converts the image.
"Input buffer contains unsupported image format"
Angular 14.
Insert Image Settings:
Front Events:
Backend:
newBuffer = image buffer
"Input buffer contains unsupported image format"
Hello Vinitha,
sorry for my english.
I'm using rich text editor in my web aplication. I need to save the image in our AWS server and replace the generated URL on HTML text, making HTML size smaller.
The HTML will be use in our FAQ texts.
So i configured the saveUrl passing the backend save route:
Before upload the image, we check size and set on currentRequest the authorization to execute saveUrl.
In backend, i need to process the image, getting the buffer from rich text save url request and converting to WEBP, using the module "sharp".
So, first, we're using "parse-multipart" module to parse the request body.
After getting the parts, we convert the image, using the "sharp" module, to WEBP image.
After upload imagem success, replace URL generated in HTML text:
Running localy, front-end and back-end, works well, using latin1 to get buffer data.
I'm from Brazil, by the way.
But running in production, server at USA/Miami, lambda AWS, we get this error from sharp converter:
"Input buffer contains unsupported image format"
So how we convert the body buffered from request and get real and correct image data buffer?
Hi Vinitha,
We don't know what encoding is needed to get buffer data from req.body sent by syncfusion rich text editor save image.
The problem isn't sharp module.
Using latin1 at Buffer.from works well running localy in my computer, front-end and back-end
But running our aplication at aws lambda, latin1 don't work.
Which encoding are necessary to get correct buffer data from req.body?
<ejs-richtexteditor id="defaultRTE" [insertImageSettings]="insertImageSettings" (imageUploading)="onImageSelected($event)"> </ejs-richtexteditor> |
public onImageSelected(args: any): void { // Setting Authorization Header args.currentRequest.setRequestHeader( "Authorization", "Bearer ${token key to be passed}" ); // You can also add additional parameters as key-value pair args.customFormData = [{ name: "Syncfusion INC" }]; } |
Hi Vinitha,
It's possible change UploadFiles parameter to name File?
Because it is compatible with s3.
And, one more thing. Its possible get file data, base64 information, before send in request?
<ejs-richtexteditor id="defaultRTE" (dialogOpen)="dialogOpen($event)" > </ejs-richtexteditor> public dialogOpen() { (document.getElementsByClassName('e-uploader')[0] as any).name = 'file'; } |