Skip to content

Commit 0482934

Browse files
renuvkelkarpr-Maisjauntybrain
authored
docs(storage-resize-image): add a sample for using events (#1937)
Co-authored-by: Mais Alheraki <[email protected]> Co-authored-by: Pavel <[email protected]>
1 parent c7befc0 commit 0482934

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

storage-resize-images/PREINSTALL.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,22 @@ The extension automatically copies the following metadata, if present, from the
1313

1414
The extension supports resizing images in `JPEG`, `PNG`, `WebP`, `GIF`, `AVIF` and `TIFF` formats, and the output can be in one or more of these formats.
1515

16-
The extension can publish a resize completion event which you can optionally enable when you install the extension. If you enable events, you can [write custom event handlers](https://firebase.google.com/docs/extensions/install-extensions#eventarc) that respond to these events. You can always enable or disable events later. Events will be emitted via Eventarc.
16+
The extension can publish a resize completion event, which you can optionally enable when you install the extension. If you enable events, you can write custom event handlers that respond to these events. You can always enable or disable events later. Events will be emitted via Eventarc.
17+
18+
Furthermore, you can choose if you want to receive events upon the successful completion of the image resizing. Hence, you can do anything based on the event you will receive. For example, you can use [EventArc gen2 functions](https://firebase.google.com/docs/functions/custom-events#handle-events) to be triggered on events published by the extension.
19+
### Example Event Handler for Successful Resize Operation
20+
```typescript
21+
import * as functions from 'firebase-functions';
22+
import { onCustomEventPublished } from 'firebase-functions/v2/eventarc';
23+
24+
export const onImageResized = onCustomEventPublished(
25+
"firebase.extensions.storage-resize-images.v1.onSuccess",
26+
(event) => {
27+
functions.logger.info("Resize Image is successful", event);
28+
// Additional operations based on the event data can be performed here
29+
return Promise.resolve();
30+
}
31+
);
1732

1833
#### Detailed configuration information
1934

storage-resize-images/README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,22 @@ The extension automatically copies the following metadata, if present, from the
2121

2222
The extension supports resizing images in `JPEG`, `PNG`, `WebP`, `GIF`, `AVIF` and `TIFF` formats, and the output can be in one or more of these formats.
2323

24-
The extension can publish a resize completion event which you can optionally enable when you install the extension. If you enable events, you can [write custom event handlers](https://firebase.google.com/docs/extensions/install-extensions#eventarc) that respond to these events. You can always enable or disable events later. Events will be emitted via Eventarc.
24+
The extension can publish a resize completion event, which you can optionally enable when you install the extension. If you enable events, you can write custom event handlers that respond to these events. You can always enable or disable events later. Events will be emitted via Eventarc.
25+
26+
Furthermore, you can choose if you want to receive events upon the successful completion of the image resizing. Hence, you can do anything based on the event you will receive. For example, you can use [EventArc gen2 functions](https://firebase.google.com/docs/functions/custom-events#handle-events) to be triggered on events published by the extension.
27+
### Example Event Handler for Successful Resize Operation
28+
```typescript
29+
import * as functions from 'firebase-functions';
30+
import { onCustomEventPublished } from 'firebase-functions/v2/eventarc';
31+
32+
export const onImageResized = onCustomEventPublished(
33+
"firebase.extensions.storage-resize-images.v1.onSuccess",
34+
(event) => {
35+
functions.logger.info("Resize Image is successful", event);
36+
// Additional operations based on the event data can be performed here
37+
return Promise.resolve();
38+
}
39+
);
2540

2641
#### Detailed configuration information
2742

0 commit comments

Comments
 (0)