Skip to content
This repository has been archived by the owner on Nov 9, 2023. It is now read-only.

Passing variable with transforms option #1

Open
vikasg603 opened this issue Nov 21, 2020 · 0 comments
Open

Passing variable with transforms option #1

vikasg603 opened this issue Nov 21, 2020 · 0 comments

Comments

@vikasg603
Copy link

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 ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant