Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion storage-resize-images/POSTINSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ The extension also copies the following metadata, if present, from the original
- [`Content-Type`](https://developer.mozilla.org/docs/Web/HTTP/Headers/Content-Type)
- [user-provided metadata](https://cloud.google.com/storage/docs/metadata#custom-metadata) (except Firebase storage download tokens)

Note that if you configured the `Cache-Control header for resized images` param, the specified value will overwrite the value copied from the original image. Learn more about image metadata in the [Cloud Storage documentation](https://firebase.google.com/docs/storage/).
Be aware of the following when using this extension:

- Each original image must have a valid [image MIME type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types#Image_types) specified in its [`Content-Type` metadata](https://developer.mozilla.org/docs/Web/HTTP/Headers/Content-Type) (for example, `image/png`).

- If you configured the `Cache-Control header for resized images` parameter, your specified value will overwrite the value copied from the original image. Learn more about image metadata in the [Cloud Storage documentation](https://firebase.google.com/docs/storage/).

### Monitoring

Expand Down
4 changes: 4 additions & 0 deletions storage-resize-images/functions/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ logs.init();
exports.generateResizedImage = functions.storage.object().onFinalize((object) => __awaiter(this, void 0, void 0, function* () {
logs.start();
const { contentType } = object; // This is the image MIME type
if (!contentType) {
logs.noContentType();
return;
}
const isImage = validators.isImage(contentType);
if (!isImage) {
logs.contentTypeInvalid(contentType);
Expand Down
3 changes: 3 additions & 0 deletions storage-resize-images/functions/lib/logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ const config_1 = require("./config");
exports.complete = () => {
console.log("Completed execution of extension");
};
exports.noContentType = () => {
console.log(`File has no Content-Type, no processing is required`);
};
exports.contentTypeInvalid = (contentType) => {
console.log(`File of type '${contentType}' is not an image, no processing is required`);
};
Expand Down
5 changes: 5 additions & 0 deletions storage-resize-images/functions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ export const generateResizedImage = functions.storage.object().onFinalize(
logs.start();
const { contentType } = object; // This is the image MIME type

if (!contentType) {
logs.noContentType();
return;
}

const isImage = validators.isImage(contentType);
if (!isImage) {
logs.contentTypeInvalid(contentType);
Expand Down
4 changes: 4 additions & 0 deletions storage-resize-images/functions/src/logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export const complete = () => {
console.log("Completed execution of extension");
};

export const noContentType = () => {
console.log(`File has no Content-Type, no processing is required`);
};

export const contentTypeInvalid = (contentType: string) => {
console.log(
`File of type '${contentType}' is not an image, no processing is required`
Expand Down