This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function (RED) { | |
var LowerCaseNode = /** @class */ (function () { | |
function LowerCaseNode(config) { | |
RED.nodes.createNode(this, config); | |
this.on('input', function (msg) { | |
msg.payload = msg.payload.toLowerCase(); | |
this.send(msg); | |
}); | |
} | |
return LowerCaseNode; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function (RED: Red) { | |
class LowerCaseNode { | |
constructor(config: NodeProperties) { | |
RED.nodes.createNode(this, config); | |
this.on('input', function(msg: any) { | |
msg.payload = msg.payload.toLowerCase(); | |
this.send(msg); | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(RED) { | |
function LowerCaseNode(config) { | |
RED.nodes.createNode(this,config); | |
var node = this; | |
node.on('input', function(msg) { | |
msg.payload = msg.payload.toLowerCase(); | |
node.send(msg); | |
}); | |
} | |
RED.nodes.registerType("lower-case", LowerCaseNode) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
lambda::gateway::start(|req| { | |
//... | |
let encoded_thumbnail = encode_png_image(thumbnail)?; | |
let encoded_thumbnail = base64::encode(&encoded_thumbnail); | |
let res = lambda::gateway::response() // Create a response | |
.status(200) // Set HTTP status code as 200 (Ok) | |
.body(lambda::gateway::Body::from(encoded_thumbnail))?; // Convert the encoded_thumbnail to |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn encode_png_image(image: DynamicImage) -> Result<Vec<u8>, ImageError> { | |
let mut result: Vec<u8> = Vec::new(); // Creates the output `Vec<u8>` | |
image.write_to(&mut result, ImageOutputFormat::PNG)?; // Writes `image` to `result` as a PNG | |
Ok(result) | |
} | |
fn main() { | |
lambda::gateway::start(|req| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
lambda::gateway::start(|req| { | |
//... | |
let image = load_from_memory(&image)?; | |
let thumbnail = image.thumbnail(128, 128); // Create the 128x128 thumbnail | |
// ... | |
}) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate aws_lambda as lambda; | |
extern crate image; | |
use image::{DynamicImage, ImageError, ImageOutputFormat}; | |
use image::load_from_memory; | |
fn encode_png_image(image: DynamicImage) -> Result<Vec<u8>, ImageError> { | |
let mut result: Vec<u8> = Vec::new(); | |
image.write_to(&mut result, ImageOutputFormat::PNG)?; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
lambda::gateway::start(|req| { | |
let base64_image: &str = req.body().as_str()?; | |
let image: Vec<u8> = base64::decode(base64_image)?; // Decode base64 image | |
let image: DynamicImage = load_from_memory(&image)?; // Convert image into `DynamicImage` | |
// ... | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
lambda::gateway::start(|req| { | |
let base64_image: &str = req.body().as_str()?; | |
//... | |
}) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate aws_lambda as lambda; | |
fn main() { | |
lambda::gateway::start(|_req /* API Gateway Request */| { | |
let res = lambda::gateway::response() // Construct API Gateway Response | |
.status(200) | |
.body(lambda::gateway::Body::from("Hello, World!"))?; // Convert String to Body | |
Ok(res) // Return response | |
}) |
NewerOlder