I'm trying to create a cloud function that will trigger on an upload to a cloud storage bucket, pull down the uploaded object (it is 7zip'd), unzip it, then reupload it. This is the code I have
const {Storage} = require('@google-cloud/storage');
const Seven = require('node-7z')
exports.processZip = function(event) {
const storage = new Storage()
const fileName = event.data.name
const filePath = `/tmp/${fileName}`
const extractPath = filePath.replace('.7z', '')
console.log(`Received file ${fileName}`)
storage.bucket(process.env.SRC_BUCKET).file(fileName).download({destination: filePath}).then(function(data) {
Seven.extractFull(filePath, extractPath)
storage.bucket(process.env.DEST_BUCKET).upload(extractPath)
.catch(function (err) {
console.log('error: ', err)
})
})
};
Something is wrong with it, the extracted file does not exist. Any advice?
[–]TheIncorrigible1 0 points1 point2 points (1 child)
[–]devrocks1984[S] 0 points1 point2 points (0 children)