I’d like to know how I could detect that an object (that was recently created) is of type “folder”.
Currently, I do this with this piece of code:
export const resizeImage = onObjectFinalized({
}, async (event: CloudEvent<StorageObjectData>) => {
const fileBucket = event.data.bucket; // Storage bucket containing the file.
const filePath = event.data.name as string; // File path in the bucket.
const contentType = event.data.contentType as string; // File content type
// Check if the object created is a folder
if (contentType === 'application/octet-stream') {
return logger.log("Object created is a folder. Skipping processing.");
}
/* ...more code */)}
The problem is that there is other kind of files that its content type is equal to “application/octet-stream” (for example .drawio files).
How to know if a created object is a folder?