jasonraimondi / url-to-png

Selfhosted. URL to PNG utility featuring parallel rendering using Playwright for screenshots and with storage caching via Local, S3, or CouchDB
https://jasonraimondi.github.io/url-to-png/
MIT License
136 stars 26 forks source link

Support for local disk caching #31

Closed enstyled closed 4 months ago

enstyled commented 4 months ago

A great addition would be the option for caching the results locally, as it would be always faster and more secure than external services like S3 and CouchDB.

jasonraimondi commented 4 months ago

This should be easy if you just extend the IImageInterface

import { IImageStorage } from "../services/image-storage.service";

export class FileStorageProvider implements IImageStorage {
  constructor(private readonly logger: LoggerService) {}

  public fetchImage(imageId: string): Promise<null> {
    // use node fs api to retrieve image
  }

  public storeImage(imageId: string, image: Buffer): Promise<null> {
    // use node fs api to store image
  }
}

I would be happy to merge a PR with this support.

enstyled commented 4 months ago

Thank you so much for looking into this and adding it so fast 😊❤️