Improved storage reading

This commit is contained in:
Alexander Cerutti
2023-07-30 01:55:15 +02:00
parent 5fbf28a59b
commit 724c2af7e5

View File

@@ -242,20 +242,14 @@ export const pass = functions.https.onRequest(
await storageRef await storageRef
.file(`thumbnails/${thumbnailFile}`) .file(`thumbnails/${thumbnailFile}`)
.download({ destination: tempPath1 }); .download({ destination: tempPath1 });
const buffer = fs.readFileSync(tempPath1);
newPass.addBuffer("thumbnail.png", buffer);
newPass.addBuffer("thumbnail@2x.png", buffer);
} catch (error) { } catch (error) {
console.error(error); console.error(error);
} }
let buffer = Buffer.alloc(0);
try {
buffer = fs.readFileSync(tempPath1);
} catch (error) {
console.error(error);
}
newPass.addBuffer("thumbnail.png", buffer);
newPass.addBuffer("thumbnail@2x.png", buffer);
} }
} }
@@ -266,19 +260,14 @@ export const pass = functions.https.onRequest(
await storageRef await storageRef
.file(`logos/${logoFile}`) .file(`logos/${logoFile}`)
.download({ destination: tempPath2 }); .download({ destination: tempPath2 });
const buffer = fs.readFileSync(tempPath2);
newPass.addBuffer("logo.png", buffer);
newPass.addBuffer("logo@2x.png", buffer);
} catch (error) { } catch (error) {
console.error(error); console.error(error);
} }
let buffer = Buffer.alloc(0);
try {
buffer = fs.readFileSync(tempPath2);
} catch (error) {
console.error(error);
}
newPass.addBuffer("logo.png", buffer);
newPass.addBuffer("logo@2x.png", buffer);
} }
const bufferData = newPass.getAsBuffer(); const bufferData = newPass.getAsBuffer();