-
Notifications
You must be signed in to change notification settings - Fork 380
Closed
Description
I am trying to create a lambda service that returns a svg based on a Jira ticket. I have everything I need to create the svg, and I got my lambda service running in AWS. The problem I am having is that the endpoint will only return a base64 encoded version of the data. I am not sure what is going wrong, but I created this example project to show what is going on.
https://github.com/aquacash5/svg-aws-rs-example
Raw binary response
async fn function_handler(_event: Request) -> Result<Response<Body>, Error> {
let svg_doc = create_svg();
let mut svg_data: Vec<u8> = Vec::new();
svg::write(&mut svg_data, &svg_doc)?;
let resp = Response::builder()
.status(200)
.header("content-type", "image/svg+xml")
.body(svg_data.into())
.map_err(Box::new)?;
Ok(resp)
}Convert to string first
async fn function_handler(_event: Request) -> Result<Response<Body>, Error> {
let svg_doc = create_svg();
let mut svg_data: Vec<u8> = Vec::new();
svg::write(&mut svg_data, &svg_doc)?;
let svg_str = String::from_utf8(svg_data)?;
let resp = Response::builder()
.status(200)
.header("content-type", "image/svg+xml")
.body(svg_str.into())
.map_err(Box::new)?;
Ok(resp)
}Both versions produce the same result.
Metadata
Metadata
Assignees
Labels
No labels