This is my code block
transforms: [
{
id: 'original',
key: function (req, file, cb) {
SHA256(Date.now().toString() + Math.random().toString()).then(Hash => {
cb(null, new Date().toISOString().slice(0, 10) + '-' + Hash +'.webp');
}).catch(err => {
cb(null, new Date().toISOString().slice(0, 10) + '-' + Math.random().toString() +'.webp');
})
},
transform: function (req, file, cb) {
cb(null, sharp().webp());
},
},
{
id: 'thumbnail',
key: function (req, file, cb) {
SHA256(Date.now().toString() + Math.random().toString()).then(Hash => {
cb(null, new Date().toISOString().slice(0, 10) + '-' + Hash +'.webp');
}).catch(err => {
cb(null, new Date().toISOString().slice(0, 10) + '-' + Math.random().toString() +'.webp');
})
},
transform: function (req, file, cb) {
cb(null, sharp().resize(100, 100).jpg())
}
}
],
Now the issue is what i want is thumbnail image name to be original-thumbnail.
but as there is no way to pass variables, it's not possible for me to do this.
Is there any way to achieve this ?
This is my code block
transforms: [
{
id: 'original',
key: function (req, file, cb) {
SHA256(Date.now().toString() + Math.random().toString()).then(Hash => {
cb(null, new Date().toISOString().slice(0, 10) + '-' + Hash +'.webp');
}).catch(err => {
cb(null, new Date().toISOString().slice(0, 10) + '-' + Math.random().toString() +'.webp');
})
},
transform: function (req, file, cb) {
cb(null, sharp().webp());
},
},
{
id: 'thumbnail',
key: function (req, file, cb) {
SHA256(Date.now().toString() + Math.random().toString()).then(Hash => {
cb(null, new Date().toISOString().slice(0, 10) + '-' + Hash +'.webp');
}).catch(err => {
cb(null, new Date().toISOString().slice(0, 10) + '-' + Math.random().toString() +'.webp');
})
},
transform: function (req, file, cb) {
cb(null, sharp().resize(100, 100).jpg())
}
}
],
Now the issue is what i want is thumbnail image name to be original-thumbnail.
but as there is no way to pass variables, it's not possible for me to do this.
Is there any way to achieve this ?