Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion storage-resize-images/POSTINSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ You can test out this extension right away:

1. Go to your [Storage dashboard](https://console.firebase.google.com/project/${param:PROJECT_ID}/storage).

1. Upload an image file to the bucket: `${param:IMG_BUCKET}`
1. Upload an image file to the bucket: `${param:IMG_BUCKET}`. The file must have a valid [image MIME Type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types#Image_types), for example `image/png`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a really common case that a dev might not have the image MIME type specified? If not, then I wouldn't put this level of detail here in this uber quickstart section. Instead, I'd like to explore putting some of these known gotchas within the "Using this extension" section.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, agreed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved this "error" down in the POSTINSTALL file. Pls double-check that my change and additional text is correct? Thx!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping on this comment thread :-)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@laurenzlong Are you ok with the changes?


1. In a few seconds, the resized image(s) appear in the same bucket.

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