This is a basic boilerplate for a Node.js service that can store images in google cloud function from image-64 strings.
- Uses Sharp (AKA, very fast);
- Miniature generation support
- Serverless Framework support
- Max Sizing support
- No more Service Scale pains!
- Clone this repository
- Change the config.js File (Check the comments in that file)
- Change the serverless.yml config file
- Deploy an enjoy
POST /https://zone-project.cloudfunctions.net/base
Content-Type application/json
{
"name": "optional-file-name",
"image": "data:image/gif;base64,R0lGODlhPQBEAPeoAJosM//..."
}
{
"height": 68,
"width": 61,
"size": 2404,
"format": "jpeg",
"url": "https://www.googleapis.com/download/storage/v1/b/test-bucket-fega01/o/images%2Fimage-5fec83f0-5f7c-11e9-b15e-450ad8a47371.jpeg?generation=1555332340580861&alt=media",
"md5Hash": "iPfi/I/YVE1cgWlXoD9etg==",
"contentType": "image/jpeg",
"miniatures": [
{
"height": 68,
"width": 61,
"size": 2404,
"format": "jpeg",
"url": "https://www.googleapis.com/download/storage/v1/b/test-bucket-fega01/o/miniatures%2Fimage-6048d4c0-5f7c-11e9-b15e-450ad8a47371-100.jpeg?generation=1555332341014935&alt=media",
"md5Hash": "iPfi/I/YVE1cgWlXoD9etg==",
"contentType": "image/jpeg"
}
]
}
MIT