Working With S3 - acstech/corkboard GitHub Wiki

Development

Config

As you can see in the README, a CB_ENVIRONMENT environment variable set to a value of "dev" is necessary to access the Mock S3 for development. All other configuration, including the creation of a working directory for images, is already handled.

Mock S3

The mock S3 is written to reflect the same process the actual S3 requires when using presigned URL's. There are no well implemented Mock S3's for Golang that reflect the capability to use Presigned URL's, but the mock S3 endpoints in corkboard provide more than enough functionality for testing locally during development. A directory "/s3images" is created inside the corkboard directory. This is used as the bucket in which images will be stored.

Accessing Stored Files

To ensure that the uploaded image can be accessed later in the workflow, after uploading an image to the Mock S3, the item or user to which the image coincides should be updated to include the image GUID in the picID field. Each image GUID is a uuid V4 with the specified extension. All image file access is handled in the GetItem, GetItems, GetUser, and GetUsers endpoints by creating a presigned URL for each key in the PicID field and returning it in the response.

Production

Config

AWS Credentials

The credentials for your bucket must be loaded onto the server being used for your API. For details on AWS Credentials see the Amazon AWS SDK Docs.