I'm trying to save a processed image momentally in /tmp folder but it's not working for me. Assuming it's under the root folder I'm trying to get it this way:
let tempraryImageDirectory: string;
if (process.env.DEV && process.env.DEV === 'Yes') {
tempraryImageDirectory = path.join(__dirname, `../../tmp/`);
} else {
tempraryImageDirectory = path.join(__dirname, `./tmp/`);
}
The else choice here is to test locally. I don't want to create a /tmp folder in the root directory. Locally everything is very fine. But in Lambda at the moment any operation happens on the directory CloudWatch never shows any of my logs written after that and my function fails for unknown reason.
Any idea if I'm addressing the /tmp folder correctly?
The directory is just /tmp, it is not relative to the working directory:
let tempraryImageDirectory: string;
if (process.env.DEV && process.env.DEV === 'Yes') {
tempraryImageDirectory = path.join(__dirname, `../../tmp/`);
} else {
tempraryImageDirectory = '/tmp/';
}
You may also wish to rename your variable to include the o in temporary if you did not leave it out on purpose.
Change this: ./tmp/, i.e. "the /tmp directory under the current working directory"
To this: /tmp/, i.e. "the /tmp directory under the root file system"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With