Skip to content

ggerman/lambda-aws

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

AWS Lambda function upload images and save into different folders with differents sizes.

Target:

Get image and save this inside "products/" (folder) and "product_id" (folder) in differents sizes.

Instalation:

Requriments: Python >= 3.7

Install package:

pip install --target . json
pip install pip install --target . boto3
pip install pip install --target . requests
pip install pip install --target . PIL
pip install pip install --target . Pillow

Problem:

_Error: cannot import name 'imaging' from 'PIL' Python 3.7 runtime

Pillow swouldswould ork but the solution is download the file and decompress inside in the same folder:

Pillow-7.1.2-cp37-cp37m-manylinux1_x86_64.whl

Library

Compress the folder with the lambda function:

zip -x '.git' -x '.git/' -x 'documentation' -x 'documentation/' -r9 '../upload_images.zip' .

Upload Code to AWS Bucket and upload to the lambda function:

Box Function Code Add the URL of the zip file

gateway

add Gateway for external connection. Designer Set Gateway

Runtime Settings:

Configure the python version and name of the lambda file and function: Runtime Settings

Basic Settings

Set time for wait the function run and set the memory quantity.

Basic Settings

Bash call the lambda function:

curl -X POST -k -H 'Content-Type: application/json' -i '<API endpoint>' --data  '[{"url": "<source_image_name>", "bucket_prefix":"<prefix>", "bucket_name": "<bucket_name>", "bucket_suffix": "<suffix>", "product_id": "<folder_name>", "name": "<destination_file_name>"}]' 

Complete Official Documentation:

AWS Documentation

About

upload and resize images to aws bucket

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages