asilvas / node-image-steam

A simple, fast, and highly customizable on-the-fly image manipulation web server built atop Node.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How does the storage.cache option work?

benderunit opened this issue · comments

What I try to figure out, if it's possible to read images from /data/original/images on the server and write the cached images to /data/cache/images. Is this possible without creating a custom storage driver?

The default behavior is to create the cached folder under the original path (i.e. original /data/original and cache /data/original/isteam). One option would be to leverage the new storage.cache option: https://github.com/asilvas/node-image-steam#storage-options so you're effectively using a seperate driver instance for the cache tier. In the future it'll probably also be possible to specify read/writer configs separately.

Closing issue, but reply if anymore questions.

Hello, i'm trying to use

new imgSteam.http.Connect({
    storage: {
        driver: 'fs',
        path: __dirname + '/uploads',
        cache: {
            driver: 'fs',
            path: __dirname + '/cache'
        }
    }
}).getHandler()

Where the jpg files are in ./uploads and req.url = '/myfile.jpg' and uploads/myfile.jpg exists,
and directory cache exists.

GET /myfile.jpg/:/rs=w:650
Error: ENOENT: no such file or directory, open '/home/user/site/cache/myfile.jpg'

Could you give an example of storage configuration with fs drivers and a cache in another directory please ?

FWIW if i permute /cache and /uploads in this config, the middleware finds the file and resize it,
but it caches resized file in /uploads.

@kapouer this appears to be a bug. Once I can confirm I'll create another issue and get a patch out.