Skip to content

Easy to use upload & storage API with express and typescript.

License

Notifications You must be signed in to change notification settings

kaanersoy/upload-service

Repository files navigation

Upload/Storage API with Express & TypeScript

Coverage:

codecov

Easy to use upload & storage API with Express and TypeScript.

Also allows the resize 👇

how-to-use

Installation

Set the environment variables

# for example
PORT=300 
HOST=http://example.com

Install Dependencies

yarn install

Run the project

yarn start

Endpoints:

Upload photo:

const formData = new FormData();
// File must be a photo or something
formData.append('file', file);

const response = await fetch('/upload', {
    method: 'POST',
    body: formData,
  });
// Example response
// Save the photo url for get photo.
{
  status: "success",
  message: "Upload is successful!",
  fileName: "XCgEl-paAjW-hKNfE9XP2BTu-67uww.png",
  url: "http://example.com/uploads/XCgEl-paAjW-hKNfE9XP2BTu-67uww.png"
}

Get photo:

Do a get request to url field from response like:

GET /uploads/:photoName

That will return img that you uploaded.

Also you can get resized images with resize query param.

Example:

// This will gave you a 1000px width resized image.
GET /uploads/:photoName?resize=1000

LICENSE

See LICENSE at: LICENSE.md

About

Easy to use upload & storage API with express and typescript.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published