Avanish Shrestha
Avanish Shrestha

Reputation: 11

KeyCDN issue with expressjs API hosted on google cloud

I'm trying to push uploaded images to KeyCDN via FTP protocol in my expressjs API. When I try to push the images locally, everything is working fine. I can push properly, and the links are also working fine.

However, the API hosted on Google Cloud VM logs the push as success, but is only pushing ~80B file.

I have attached the code responsible for pushing the image file to KeyCDN.

const client = new FTP();
client.on('ready', () => {
client.put(`${process.env.UPLOAD_PATH}/${filename}`, `${filename}`, (err) => {
    if (err) {
        console.log(err, `${process.env.UPLOAD_PATH}/${filename}`);
            throw new ValidationError('Unable to upload image data.', filename);
        }
        client.end();
        console.log('Successfully pushed the image file to keyCDN.');
    });
});
client.connect({
    host: process.env.KEYCDN_HOST,
    port: process.env.KEYCDN_PORT,
    user: process.env.KEYCDN_USER,
    password: process.env.KEYCDN_PWD,
    secure: true,
});

Upvotes: 1

Views: 106

Answers (0)

Related Questions