Skip to content

Commit

Permalink
Merge pull request #61 from dwyl/api-#53
Browse files Browse the repository at this point in the history
[PR] Adding API that consumes image files
  • Loading branch information
nelsonic committed Jun 14, 2023
2 parents a6596c6 + bce4d47 commit aaa7760
Show file tree
Hide file tree
Showing 22 changed files with 900 additions and 122 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@ jobs:
- name: Run Tests
run: mix coveralls.json
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MIX_ENV: test
AUTH_API_KEY: ${{ secrets.AUTH_API_KEY }}
# https://github.com/dwyl/imgup/issues/67
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: eu-west-3

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1

Expand All @@ -55,8 +58,6 @@ jobs:
if: github.ref == 'refs/heads/main'
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
steps:
- uses: actions/checkout@v2
- uses: superfly/flyctl-actions@1.1
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ npm-debug.log
/assets/node_modules/

.env
.vscode/launch.json
22 changes: 14 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div align="center">

# Upload images to `AWS S3` via `Phoenix LiveView`
# `image uploads`

![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/dwyl/imgup/ci.yml?label=build&style=flat-square&branch=main)
[![codecov.io](https://img.shields.io/codecov/c/github/dwyl/imgup/main.svg?style=flat-square)](https://codecov.io/github/dwyl/imgup?branch=main)
Expand All @@ -15,7 +15,7 @@ using `Phoenix + LiveView`.

<br />

- [Upload images to `AWS S3` via `Phoenix LiveView`](#upload-images-to-aws-s3-via--phoenix-liveview)
- [`image uploads`](#image-uploads)
- [Why? 🤷](#why-)
- [What? 💭](#what-)
- [Who? 👤](#who-)
Expand Down Expand Up @@ -148,9 +148,15 @@ and add your credentials to it:
```sh
export AWS_ACCESS_KEY_ID='YOUR_KEY'
export AWS_SECRET_ACCESS_KEY='YOUR_KEY'
export AWS_REGION='eu-west-3'
```

In your terminal, run `source .env` to export the keys.
We are assuming all of the resources created in your application
will be on the same reason.
This env variable will be used on two different occasions:
- on our LiveView.
- on our API (check [`api.md`](api.md)) with a package called `ex_aws`.


### 3. Download the Dependencies and Run the App!
Expand Down Expand Up @@ -695,9 +701,9 @@ parameter of `allow_upload/3`.
key = "public/#{entry.client_name}"

config = %{
region: "eu-west-3",
access_key_id: System.fetch_env!("AWS_ACCESS_KEY_ID"),
secret_access_key: System.fetch_env!("AWS_SECRET_ACCESS_KEY")
region: System.get_env("AWS_REGION"),
access_key_id: System.get_env("AWS_ACCESS_KEY_ID"),
secret_access_key: System.get_env("AWS_SECRET_ACCESS_KEY")
}

{:ok, fields} =
Expand All @@ -714,7 +720,7 @@ parameter of `allow_upload/3`.
```

This function will be called
everytime the person wants to
every time the person wants to
*upload the selected files to `AWS S3` bucket,
i.e. presses the "Upload" button.

Expand Down Expand Up @@ -2195,8 +2201,8 @@ Change it like so:

config = %{
region: "eu-west-3",
access_key_id: System.fetch_env!("AWS_ACCESS_KEY_ID"),
secret_access_key: System.fetch_env!("AWS_SECRET_ACCESS_KEY")
access_key_id: System.get_env("AWS_ACCESS_KEY_ID"),
secret_access_key: System.get_env("AWS_SECRET_ACCESS_KEY")
}

{:ok, fields} =
Expand Down
Loading

0 comments on commit aaa7760

Please sign in to comment.