Giter Club home page Giter Club logo

simple-gcp-image-server's Introduction

Simple GCP Image Server

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.

Install

  1. Log in Google Cloud Platform and open Google Cloud Shell
  2. Clone this repo
  3. Install packages composer install (You have to install Composer by hand)
  4. Edit src/settings.php
  5. 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
  6. Deploy the service gcloud app deploy [app.yaml]

How to Use

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="
}

HTTPie

http -f POST 'http://example.com/upload' upload-image@/path/to/image-file

cURL

curl -X POST --url http://example.com/upload -H 'content-type: multipart/form-data' -F upload-image=@/path/to/image-file

Todo

  1. Valid/Limit requests or anyone can upload any file to server
  2. Unit tests

Contributing

You can run the service with a local development server, or on GCP.

See CONTRIBUTING.md.

License

WTFPL

simple-gcp-image-server's People

Contributors

gundamew avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.