Home Sending files through AWS Lambda
Reply: 0

Sending files through AWS Lambda

user3536 Published in April 26, 2018, 1:46 pm

I have been using simple AWS Lamda functions and their SES service to create website contact forms. I make a simple form in HTML then convert the information entered in to a JSON string object and email it to the site owner. Now I want to add the capability to upload different files that I intend to use a similar method to attach the files and email it using AWS Lambda and SES. Here is my current status and code.

Here is the code I use to make a JSON Object that I later email through AWS Lambda

$(document).ready(function() {

                $("#submit2").click(function(e) {

                    var Firstname = $("#Firstname").val(),
                        Lastname = $("#Lastname").val(),
                        email = $("#email").val(),
                        phone = $("#Phone").val(),
                        address = $("#Address").val(),
                        backSplash = $("#BackSplash").val(),
                        material = $("#Material").val(),
                        message = $("#subject").val();

                        type: "POST",
                        contentType: 'application/json',
                        data: JSON.stringify({
                            'name': Firstname + " " + Lastname,
                            'address': address,
                            'email': email,
                            'backSplash' : backSplash,
                            'material': material,
                            'message': message
                        success: function(res){
                            $('#form-response').text('Your Message Has been sent.');
                        error: function(){
                            $('#form-response').text('Error, Message was not sent, please try again.');



In Terms of uploading files, here is my current code

            function getFiles(){

                    var files = document.getElementById("myFiles").files;
                    var myArray = [];
                    var file = {};

                    console.log(files); // see the FileList

                    // manually create a new file obj for each File in the FileList
                    for(var i = 0; i < files.length; i++){
                      file = {
                          'lastMod'    : files[i].lastModified,
                          'lastModDate': files[i].lastModifiedDate,
                          'name'       : files[i].name,
                          'size'       : files[i].size,
                          'type'             : files[i].type,
                      //add the file obj to your array
                        //save the array to localStorage

How can I add the uploaded File to the data object I pass to my AWS Lamda function? and how can I allow the website owner to access it?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.457502 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO