Sending Files to Endpoints Using Base64
The simplest way to send files to your Beam endpoint is to use Base64 encoding. In the example below, we will use this method to send an image to an endpoint. The first step is to define an endpoint that accepts an encoded string.beam deploy app.py:image_endpoint
. The simple script below can be used to send an image to the endpoint.
Using S3 to Send Files
With Beam, you can easily mount S3 buckets to your endpoints and web servers. This allows you to upload files to S3 and access them in your endpoint or web server. This method is recommended if you are sending large payloads (20+ MB). Another benefit of using S3 is that you will not need to include decoding logic in your endpoint. We can modify our previous example by accepting a filename and reading the image from a mounted S3 bucket. Our frontend will need to upload the image to the S3 bucket and then pass the filename to our endpoint.beam deploy app.py:image_endpoint
.
To test this method, we can upload an image to the S3 bucket using the AWS CLI and then pass the filename to our endpoint.