- Selfhostable
- Simple upload API
- 100% file based - no database needed
- Change and resize your uploads just by editing the URL
- Securized by secret/public key pair
- Correctly rendered rotation
- Upload file
- Secret / public key pair authentication
- Duplicate detection
docker run \
--env "SECRET_KEY=<change-it>" \
--publish 3000:3000/tcp \
--volume "${PWD}/images:/data/images" \
--name image-storage \
qmachard/image-storage
version: "3.7"
services:
image-storage:
image: qmachard/image-storage:latest
container_name: "image-storage"
environment:
- SECRET_KEY=<change-it>
volumes:
- <your-path>:/data/images
- NodeJS v16.15+
- Clone or download project
$ git clone [email protected]:qmachard/image-storage.git
- Create
.env
# .env
PORT=3000
IMAGE_STORAGE=/path/to/directory
SECRET_KEY=change-it
- Build and start project
$ yarn && yarn build
$ yarn start
- Generate secret / public keys pair
$ node ./generateKey.js
- You can use your API from port
3000
Signature is a Base64 encoded string which contains values : secret
, iv
and timestamp
.
const signature = Base64(`${secret}.${iv}.${timestamp}`);
Signature can be passed as header X-API-SIGNATURE
or query params signature
.
POST /images{?signature}
+ Headers
X-API-SIGNATURE=<signature>
+ Body
Content-Disposition: form-data; name="image"; filename="IMG_E2355.jpg"
<content>
+ Response 201 (application/json)
{
"url": "/images/3e61302a-42cc-4499-8587-5ddcea90f08e.jpeg",
"filename": "3e61302a-42cc-4499-8587-5ddcea90f08e.jpeg",
"mimetype": "image/jpeg"
}
GET /images/{filename.ext}{?w}{?h}{?signature}
+ Headers
X-API-SIGNATURE=<signature>
+ Response 200 (image/jpeg)
<content>
parameter | description | default |
---|---|---|
w | Max with of image in px | null |
h | Max height of image in px | null |
signature | Signature from secretKey | null |