Coder Social home page Coder Social logo

lambda-gyazo-s3's Introduction

lambda-gyazo-s3

AWS Lambda function to provide a Gyazo server clone with S3 backend using Amazon API Gateway. While you can modify a client instead of adapting a server and use S3 directly for this purpose, this is implemented for my practice.

Build

$ gradle buildZip

Test

# Request to real Gyazo
$ UPLOAD=~/Pictures/a.png rake

# Request to API gateway
$ UPLOAD=~/Pictures/a.png API_ID= rake

Specification

Implemented to work as Gyazo server for Gyazo client.

Status: 200

> POST /upload.cgi HTTP/1.1
> Host: upload.gyazo.com
> Accept: */*
> Content-Length: 335996
> Content-Type: multipart/form-data; boundary=----BOUNDARYBOUNDARY----
> User-Agent: Gyazo/2.0
>
------BOUNDARYBOUNDARY----
content-disposition: form-data; name="id"

#{id}
------BOUNDARYBOUNDARY----
content-disposition: form-data; name="imagedata"; filename="gyazo.com"

#{imagedata}
------BOUNDARYBOUNDARY----

< HTTP/1.1 200 OK
< Server: nginx/1.6.2
< Date: Sat, 04 Feb 2017 10:32:56 GMT
< Content-Type: text/html; charset=utf-8
< Connection: keep-alive
< X-Content-Type-Options: nosniff
< X-Gyazo-Id: 0123456789abcdef0123456789abcdef
< X-Request-Id: 01234567-89ab-cdef-0123-456789abcdef
< X-Runtime: 0.047343
<
https://gyazo.com/0123456789abcdef0123456789abcdef

Status: 400

> POST /upload.cgi HTTP/1.1
> Host: upload.gyazo.com
> Accept: */*
> User-Agent: Gyazo/2.0
>
< HTTP/1.1 400 Bad Request
< Server: nginx/1.6.2
< Date: Sat, 04 Feb 2017 10:32:56 GMT
< Content-Type: text/plain; charset=utf-8
< Content-Length: 13
< Connection: keep-alive
< X-Content-Type-Options: nosniff
<
No imagedata

API Gateway Configuration

Specify com.github.k0kubun.lambda.gyazo.GyazoHandler::post in Lambda.

Method Request

Model Schema (multipart/form-data)

{}

Integration Request

Body Mapping Templates (multipart/form-data)

#set($inputParams = $util.base64Encode($input.path('$')))
#set($contentType = $input.params().header.get("Content-Type"))
{
  "body": "$inputParams",
  "contentType": "$contentType"
}

Integration Response

Body Mapping Templates (200, text/html)

$input.path('$')

Lambda Error Regex (400)

No .* given!

Method Response

Model Schema (200, text/html)

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "Empty Schema",
  "type": "object"
}

Model Schema (400)

No models

License

MIT License

lambda-gyazo-s3's People

Contributors

k0kubun avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar  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.