How does the storage.cache option work?
benderunit opened this issue · 5 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.