Code Monkey home page Code Monkey logo

imghost's Introduction

Simple image hoster

Usage:

npm start

Envs:

DOMAIN_NAME default: localhost

HOST_PORT default: 3000

PROTOCOL default: http

STORAGE_PATH default: ./files

MONGO_CONNECT default: mongodb://localhost/imagehoster

Http/s API

Uploading:

POST http://localhost:3234/upload
Content-Type: multipart/form-data

In request body must be 1 parameter with name "file".

Example of success response:

{
  "url": "http://localhost:3234/images/3SSU9PrP8CthgEWobCfKKetBL8q8.png"
}

Uploading with curl:

curl -v -F "file=@${FILE_NAME}" ${DOMAIN}/upload

Example:

curl -v -F "file=@../cat.jpg" http://localhost:3000/upload

Fetching:

Simple (without resizing):

GET http://localhost:3000/images/{FILE_ID}.{EXTENSION}

http://localhost:3000/images/3SSU9PrP8CthgEWobCfKKetBL8q8.png

With resizing:

GET http://localhost:3000/images/{WIDTH}x{HEIGHT}/{FILE_ID}.{EXTENSION}

http://localhost:3000/images/100x100/3SSU9PrP8CthgEWobCfKKetBL8q8.png

Proxy:

Image will be downloaded first time and cached

Simple (without resizing):

GET http://localhost:3000/proxy/{IMAGE_URL}

http://localhost:3000/proxy/https://i.gifer.com/1HOf.gif

With resizing:

GET http://localhost:3000/proxy/{WIDTH}x{HEIGHT}/{IMAGE_URL}

http://localhost:3000/proxy/859x356/https://i.gifer.com/1HOf.gif

You can proxy images that have been uploaded to this hosting too:

Link http://localhost:3000/proxy/100x100/http://localhost:3000/images/3SSU9PrP8CthgEWobCfKKetBL8q8.png will have same effect as: http://localhost:3000/images/100x100/3SSU9PrP8CthgEWobCfKKetBL8q8.png

But it good idea to reformat that links in short form, otherwise we can take urls like:

http://localhost:3000/proxy/100x100/http://localhost:3000/proxy/320x320/http://localhost:3000/proxy/http://localhost:3000/images/3SSU9PrP8CthgEWobCfKKetBL8q8.png

imghost's People

Contributors

b1acksun avatar bacher avatar

Watchers

 avatar

Forkers

feruzm

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.