# Create a lambda that accepts an image file via POST request

**URL:** <https://forum.serverless.com/t/create-a-lambda-that-accepts-an-image-file-via-post-request/3455>\
**Category:** Serverless Framework\
**Created:** [January 8, 2018, 11:57am UTC](https://forum.serverless.com/t/create-a-lambda-that-accepts-an-image-file-via-post-request/3455 "2018-01-08T11:57:38Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![bbilger](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/bbilger/32/1066_2.png) [@bbilger](https://forum.serverless.com/u/bbilger)\
**Post date:** [January 8, 2018, 11:44pm UTC](https://forum.serverless.com/t/create-a-lambda-that-accepts-an-image-file-via-post-request/3455/2 "2018-01-08T23:44:36Z")

</div>

Hi @amitm02 ,  
You’ll need to configure binary media types (e.g. image/png, image/gif, etc.) AND you need to pass a corresponding Content-Type header.  
Setting up binary media types cannot be configured natively in serverless, yet, but there’s a plugin for this.

The following links might help:

- [Apig + lambda-proxy + multipart-formdata](http://forum.serverless.com/t/apig-lambda-proxy-multipart-formdata/2548)
- [https://github.com/serverless/serverless/issues/2797](https://github.com/serverless/serverless/issues/2797)
- [Returning binary data (jpg) from Lambda via API Gateway](http://forum.serverless.com/t/returning-binary-data-jpg-from-lambda-via-api-gateway/796)

Once you setup binary media types and POST an image with a “matching” Content-Type header, the binary data will be base64 encoded. This means the body will be base64 encoded and the property “isBase64Encoded” will be set to true.

Note: Binary media types are applied to requests and responses and require appropriate Content-Type and Accept headers.

Also keep in mind that there’s a limit of 10MB. So using S3 instead might be beneficial in some situations.

---

_[View the full topic](https://forum.serverless.com/t/create-a-lambda-that-accepts-an-image-file-via-post-request/3455)._
