Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
August 28, 2022 10:50 pm GMT

Disco.pics - Free and open source image hosting service

Overview of My Submission

I'm a huge fan of discord, and use it to communicate with my friends, family and teammates.

One day, a friend of mine told me how he has made a channel just to store and organize his images at one place.
All attachments uploaded to discord have a link automatically generated. These links are shareable, but they are really long.
Discord has a very high-speed content delivery network (CDN) powered by Cloudflare.

All of this made us think, "Why not create an image hosting that uses discord's CDN?"

And that's exactly what we did!
But this needed to be BLAZINGLY fast. We wanted to make a good image hosting, with custom embed support, an API, etc.

This would mean, we have to fetch from the database every time someone loads an image. Redis was the perfect choice for us.

Submission Category:

Wacky Wildcards!

Overview video

Language Used

Typescript

Link to Code

GitHub logo discopics / disco.pics

An image hosting service that uses discord's CDN to store the images

Disco.pics

Fast image hosting made easy.

OGIMG

Main page

Embed builder

How it works

How the data is stored

There are two different schemas, the User and Image schema.

For each user, this is the information that is stored:

  • id: string
  • email: string
  • created_at: date
  • token_number: number
  • embed_title: string
  • embed_site_name: string
  • embed_site_url: string
  • embed_colour: string
  • embed_author_name: string
  • embed_desc: string

here, the ID is indexed, so we can find users by their ID.

The Image schema is the information that is stored for each image:

  • uploaded_by: string
  • slug: string
  • img_url: string
  • uploaded_at: date

Here, slug and uploaded_by are indexed.

Whenever someone visits the /[slug] route, the Image schema is queried for the image with the slug.

Then, using the uploaded_by, embed information is queried from the User schema.

How the data is accessed

All data is retrieved using redis-om package. The frontend makes requests through the /api routes. Then, the backend accesses functions from lib/redis.ts

Additional Resources / Info

OGIMG

Main page

Embed builder

Collaborators

@yxsh


Original Link: https://dev.to/dhravya/discopics-free-and-open-source-image-hosting-service-ia9

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To