You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This project is experimenting with different providers of cloud based web hooks and storage.
3
-
[Note: This is in the very early stages of the experimentation and is not currently functional. The specs and approach may change without any notice.]
1
+
# ImageAPI-GCP
2
+
This sub-project implements a basic Image management API in GCP. (index.js)
4
3
5
-
The base use case is the ability to upload remote images into a cloud storage bucket as well as to retrieve and resize them.
6
-
(Note: some providers have resizing capabilities inbuilt [eg. GCP], this project will examine other methods to implement the same)
4
+
Please note: `index.js` contains the latest functioning code. `experiments/` is from my initial experimentation and may not be functional.
7
5
8
-
## API Requirements
9
-
- Upload Images via URL
10
-
- Download Images / provide Signed URL
11
-
- Resize Images
12
-
- 80 day expiry
13
-
14
-
### Additional Considerations
15
-
- Real time updates for large uploads
16
-
- Performance [Optimization for write heavy load]
17
-
- Caching
18
-
- Security [Who can access which images]
19
-
- Resilience []
6
+
## Current State
7
+
The first phase on this module has been completed.
8
+
This encompasses the basic functionality of uploading a remote image (via stream), and providing a signed URL by which to access that image. It consists of one REST end point.
20
9
21
10
## Setup
22
11
1. Create Project and add Project_ID to config.json
23
12
2. Create a service account with access to upload Google Functions and save the key in keys/gcp_functions.json
24
13
3. Create Bucket in Google Cloud Storage and update bucket_name in config.json
25
14
4. Create a service account with write permissions to your google storage bucket and save the key in keys/gcp_storage.json
26
-
TODO: add script to deploy.sh to add Project_ID to bucket name
The API endpoint footprint is small and doesn't need to maintain any state. This makes it a prime candidate for Lamba-style webhooks. (Benefits: Auto-scaling, minimal upkeep, smaller code footprint etc.)
48
-
User will interact with a single REST endpoint (/images) through GET and PUT requests.
49
-
50
-

20
+
- Match Cache expiry to Bucket item expiration
21
+
- Add script to deploy.sh to add Project_ID to bucket name
22
+
- Security and signing
51
23
52
-

53
-
54
-
55
-
### Provider
56
-
Note: GCP's Node 8 driver is still Beta.
57
-
58
-
### Implementation
24
+
## Implementation Notes
59
25
#### Item Expiry
60
26
The item expiry can be handled directly in the data bucket policy.
61
27
`gsutil mb --retention 80d gs://ImageAPI`
62
28
(For a more nuanced/extensible approach we could specify a more detailed lifecycle policy or have a lambda function launched via scheduled CRON job - eg. via cloud scheduler)
We're currently utilizing Google's prebuilt node module for access. For a smaller footprint, to aid with speed of load for the cloud functions, we could use a streamlined request library to interact directly with their REST API.
0 commit comments