FT_compressedThumbnail: add path exclusions

This commit is contained in:
Sidney Alcantara
2020-08-05 19:53:50 +10:00
parent b32887babd
commit 08b9f0cda0
2 changed files with 17 additions and 16 deletions

View File

@@ -17,9 +17,15 @@ import config from "../functionConfig";
const SUPPORTED_TYPES = ["image/jpeg", "image/png"];
const DEFAULT_SIZES = ["400x400", "200x200", "100x100"];
const sizes =
Array.isArray(config) && typeof config[0] === "string"
? config
config && Array.isArray(config.sizes) && typeof config.sizes[0] === "string"
? config.sizes
: DEFAULT_SIZES;
const excludePaths =
config &&
Array.isArray(config.excludes) &&
typeof config.excludes[0] === "string"
? config.excludes
: [];
export const FT_compressedThumbnail = functions.storage
.object()
@@ -43,6 +49,14 @@ export const FT_compressedThumbnail = functions.storage
const token = object.metadata?.firebaseStorageDownloadTokens;
const filePath = object.name!;
// Check if file should be excluded based off path
for (const excludePath of excludePaths)
if (filePath.startsWith(excludePath)) {
console.log("File excluded from path", excludePath);
return null;
}
const baseFileName = path.basename(filePath, path.extname(filePath));
const tempLocalFile = path.join(
os.tmpdir(),

View File

@@ -1,15 +1,2 @@
export default {
onUpdate: true,
onCreate: false,
source: "advisors",
fieldsToSync: [
"firstName",
"lastName",
"preferredName",
"profilePhoto",
"email",
"location",
],
target: "coaches",
};
export default {} as any;
export const collectionPath = "";