Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PR] Adding API that consumes image files #61

Merged
merged 34 commits into from
Jun 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
c4076a6
feat: Adding homepage and README guides. #53
LuchoTurtle Jun 5, 2023
144c9d5
feat: Adding response controller to API requests. #53
LuchoTurtle Jun 5, 2023
52a3a7a
feat: Adding file upload with filetype and size limiting. #53
LuchoTurtle Jun 6, 2023
95a6d9a
feat: Adding README. #53
LuchoTurtle Jun 6, 2023
47a2c6c
feat: Adding public ACL read and URL. #53
LuchoTurtle Jun 6, 2023
a8e0c23
feat: Adding tests. #53
LuchoTurtle Jun 7, 2023
240e30a
feat: Adding CID. #53
LuchoTurtle Jun 7, 2023
aa5e528
feat: Add API info to homepage. #53
LuchoTurtle Jun 7, 2023
4c932ca
Merge branch 'master' into api-#53
LuchoTurtle Jun 7, 2023
fc5b4bb
fix minor typo in api.md
nelsonic Jun 7, 2023
eacf854
fix: Removing dead code. Adding region config. Commenting xpath usage.
LuchoTurtle Jun 12, 2023
2bb3c80
split uploading into a separate function
nelsonic Jun 13, 2023
4ffce22
abstract S3 upload code into separate library lib/app/upload.ex https…
nelsonic Jun 13, 2023
147f6e6
create test/app/upload_test.exs to test the generic upload function h…
nelsonic Jun 13, 2023
374ce3a
substantially simplify api_controller and actually test everything. #53
nelsonic Jun 13, 2023
52b6cbd
add AWS_ACCESS_KEY_ID to .github/workflows/ci.yml fixes #67
nelsonic Jun 14, 2023
c3723ad
attempt to use aws-actions/configure-aws-credentials@v2 to set AWS en…
nelsonic Jun 14, 2023
1070fcb
comment out echo set-env https://github.com/dwyl/imgup/actions/runs/5…
nelsonic Jun 14, 2023
114d917
define role-to-assume in ci.yml #67
nelsonic Jun 14, 2023
bd8bac7
use secrets.CI_AWS_SECRET_ACCESS_KEY #67
nelsonic Jun 14, 2023
741e525
use secrets.CI_AWS_SECRET_ACCESS_KEY #67
nelsonic Jun 14, 2023
2db960f
comment out "aws-actions/configure-aws-credentials@v2" #67
nelsonic Jun 14, 2023
06a6254
move environment variable definition higher in ci.yml #67
nelsonic Jun 14, 2023
e3a2da5
System.get_env("CI_AWS_SECRET_ACCESS_KEY") #67
nelsonic Jun 14, 2023
6bba2cf
replace System.fetch_env!/1 with System.get_env/1 #67
nelsonic Jun 14, 2023
6791bf3
replace System.fetch_env!/1 with System.get_env/1 https://github.com/…
nelsonic Jun 14, 2023
82b55fd
replace System.fetch_env!/1 with System.get_env/1 https://github.com/…
nelsonic Jun 14, 2023
ce7ac23
ensure env in ci.yml #67
nelsonic Jun 14, 2023
5bcafb0
secrets.CI_AWS_SECRET_ACCESS_KEY > secrets.AWS_SECRET_ACCESS_KEY #67
nelsonic Jun 14, 2023
187e33a
remove redundant config in test.exs #67
nelsonic Jun 14, 2023
942134d
fix config typo #67
nelsonic Jun 14, 2023
2f50de8
add instructions for testing with Hoppscotch #53 https://github.com/d…
nelsonic Jun 14, 2023
40e95f4
add upload/1 test to api.md https://github.com/dwyl/imgup/pull/61#dis…
nelsonic Jun 14, 2023
bce4d47
replace System.fetch_env! with System.get_env in README.md for consis…
nelsonic Jun 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading