For the complete documentation index, see llms.txt. This page is also available as Markdown.

Hello World with S3 file Storage


Goal

We want to add persistence using an S3 Bucket to an Hello World Application already hosted on Poja that exposes the /hello?name=your-name endpoint, for which it :

  • Writes a Hello World message inside a .txt file

  • Uploads the file to an S3 bucket

  • Returns a presigned uri to download the file

Deploy in one click

Before diving into the step-by-step guide, you can simply click the Deploy to Poja button. This will instantly deploy this template to your Poja account

Deploy to Poja

How-to in 2 steps

Step 1: Enable file storage for the preprod environment

Select the preprod environment, click on the Edit button on the Poja Configuration section and then:

  • Enable the File Storage

  • Click on the Save button

Once it’s done, wait for the deployment to finish.

/health/bucket

Once the File Storage option is activated, /health/bucket endpoint will be added to the application. It returns a presigned URI which gives you read-only access to tiny files created in the bucket for testing purpose.

Step 2: Code your endpoint

The BucketComponent class

To interact with the S3 Bucket associated to your application, Poja provides the BucketComponent class which has 4 public methods:

  • upload()

  • download() to download a specific file by specifying its name

  • presign() to get a presigned uri to access a specific file for a specified duration

  • getBucketName()

To trigger a deployment, just commit and push the code to the preprod branch of the repository. Wait. And voilà!


Last updated

Was this helpful?