A simple image server run in App Engine using the standard environment.
It saving files with Cloud Storage, serving images with App Engine, and record the relationships of files and serving URLs with Cloud SQL.
This repo was created from Slim Framework 3 skeleton application and for learning to use GCP services.
- Log in Google Cloud Platform and open Google Cloud Shell
- Clone this repo
- Install packages
composer install
(You have to install Composer by hand) - Edit
src/settings.php
- Run migrations locally via Cloud SQL Proxy
phinx migrate --dry-run
will receive error message which is an known issue. Just run it w/o--dry-run
option
- Deploy the service
gcloud app deploy [app.yaml]
Send multipart/form-data
(the part name must be upload-image
) request to <YOUR_SERVICE_NAME>/upload
, and you will get response contains public_link
and serving_url
in JSON format, like this:
{
"public_url": "https://storage.googleapis.com/default-bucket/3d23fdbe1b5976fd4534636c7507de2909e9dbe0",
"serving_url": "https://lh3.googleusercontent.com/YXBwX2RlZmF1bHRfYnVja2V0LzNkMjNmZGJlMWI1OTc2ZmQ0NTM0NjM2Yzc1MDdkZTI5MDllOWRiZTA="
}
http -f POST 'http://example.com/upload' upload-image@/path/to/image-file
curl -X POST --url http://example.com/upload -H 'content-type: multipart/form-data' -F upload-image=@/path/to/image-file
- Valid/Limit requests or anyone can upload any file to server
- Unit tests
You can run the service with a local development server, or on GCP.
See CONTRIBUTING.md.
WTFPL