Skip to content

Commit c482de6

Browse files
committed
Video transformation + version bumps
1 parent abe2c20 commit c482de6

File tree

6 files changed

+71
-49
lines changed

6 files changed

+71
-49
lines changed

components/cloudinary/actions/get-account-usage-details/get-account-usage-details.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "cloudinary-get-account-usage-details",
55
name: "Get Account Usage Details",
66
description: "Gets a report of your Cloudinary account usage details, including storage, credits, bandwidth, requests, number of resources, and add-on usage. [See the documentation](https://cloudinary.com/documentation/admin_api#usage)",
7-
version: "0.2.{{ts}}",
7+
version: "0.2.0",
88
type: "action",
99
props: {
1010
cloudinary,

components/cloudinary/actions/get-resources/get-resources.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "cloudinary-get-resources",
55
name: "Get Resources",
66
description: "Lists resources (assets) uploaded to your product environment. [See the documentation](https://cloudinary.com/documentation/admin_api#get_resources)",
7-
version: "0.1.{{ts}}",
7+
version: "0.1.0",
88
type: "action",
99
props: {
1010
cloudinary,

components/cloudinary/actions/image-transformation/image-transformation.mjs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@ import cloudinary from "../../cloudinary.app.mjs";
33
export default {
44
key: "cloudinary-image-transformation",
55
name: "Transform Image",
6-
description: "Transform an image on-the-fly with several options. [See the documentation](https://cloudinary.com/documentation/image_transformations)",
7-
version: "0.1.{{ts}}",
6+
description: "Transform an image asset on-the-fly with several options. [See the documentation](https://cloudinary.com/documentation/image_transformations)",
7+
version: "0.1.0",
88
type: "action",
99
props: {
1010
cloudinary,
11-
imageSource: {
12-
type: "string",
13-
label: "Public ID",
14-
description: "The [public ID](https://cloudinary.com/documentation/upload_images#public_id) of the asset , e.g. `folder/filename`.",
11+
assetId: {
12+
propDefinition: [
13+
cloudinary,
14+
"assetId"
15+
]
1516
},
1617
width: {
1718
type: "integer",
@@ -40,21 +41,22 @@ export default {
4041
max: 100,
4142
},
4243
transformations: {
43-
type: "object",
44-
label: "Additional Transformations",
45-
description: "Additional transformations to apply to the image. [See the documentation](https://cloudinary.com/documentation/transformation_reference#co_color) for all available transformations. Example: `{ \"angle\": 90, \"color_space\": \"srgb\"}`",
44+
propDefinition: [
45+
cloudinary,
46+
"transformations"
47+
]
4648
},
4749
},
4850
async run({ $ }) {
49-
const { cloudinary, imageSource, transformations, ...options } = this;
51+
const { cloudinary, assetId, transformations, ...options } = this;
5052
try {
51-
const response = await cloudinary.transformImage(imageSource, {
53+
const response = await cloudinary.transformAsset(assetId, {
5254
...options,
5355
...transformations,
5456
});
5557

5658
if (response) {
57-
$.export("$summary", "Successfully transformed image.");
59+
$.export("$summary", "Successfully transformed image");
5860
}
5961

6062
return response;

components/cloudinary/actions/resource-transformation/resource-transformation.mjs

Lines changed: 43 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,58 @@ import cloudinary from "../../cloudinary.app.mjs";
22

33
export default {
44
key: "cloudinary-resource-transformation",
5-
name: "Resource Transformation",
6-
description: "Transforms image or video resources on-the-fly. It allows transformation options for resource optimization (i.e. web viewing), resize and crop the resources, etc. [Image transformation documentation](https://cloudinary.com/documentation/image_transformations). [Video transformation documentation](https://cloudinary.com/documentation/video_transformation_reference)",
7-
version: "0.2.2",
5+
name: "Transform Video or Audio",
6+
description: "Transform a video or audio asset on-the-fly with several options. [See the documentation](https://cloudinary.com/documentation/video_manipulation_and_delivery)",
7+
version: "0.3.0",
88
type: "action",
99
props: {
1010
cloudinary,
11-
resourceType: {
12-
propDefinition: [
13-
cloudinary,
14-
"transformationResourceType",
15-
],
16-
},
17-
options: {
18-
type: "string",
19-
label: "Options",
20-
description: "For an image `resourceType`, use this parameter to set the image transformation options to apply and/or the URL parameters supported by Cloudinary API. For all transformation options, please check [Image transformation API reference](https://cloudinary.com/documentation/image_transformation_reference), for URL parameters, please check [Transforming media assets using dynamic URLs](https://cloudinary.com/documentation/image_transformations#transforming_media_assets_using_dynamic_urls).\nFor a video `resourceType`, use this parameter to set video transformation options to apply and/or the URL parameters supported by Cloudinary API. For all transformation options, please check [Video transformation API reference](https://cloudinary.com/documentation/video_transformation_reference), for URL parameters, please check [Transforming media assets using dynamic URLs](https://cloudinary.com/documentation/image_transformations#transforming_media_assets_using_dynamic_urls).",
21-
},
22-
imageSource: {
23-
type: "string",
24-
label: "Image Source",
25-
description: "If `resourceType` is an image, use this parameter to point to the source of the image to apply transformations on. It can be a local file, the actual image data, a remote FTP, HTTP or HTTPS URL address of an existing image. For details and examples, see: [file source options](https://cloudinary.com/documentation/upload_images#file_source_options).",
26-
optional: true,
27-
},
28-
videoPublicId: {
29-
type: "string",
30-
label: "Video Public Id",
31-
description: "If `resourceType` is a video, use this parameter to set the public id of the video to apply transformations on. The public id is the unique identifier of the video, and is either specified when uploading the video to your Cloudinary account, or automatically assigned by Cloudinary. For more details on the options for specifying the public id, see [Public ID - the image identifier](https://cloudinary.com/documentation/upload_images#public_id).",
32-
optional: true,
33-
},
11+
assetId: {
12+
propDefinition: [
13+
cloudinary,
14+
"assetId"
15+
]
16+
},
17+
width: {
18+
type: "integer",
19+
label: "Width",
20+
description: "The new width of the video, e.g. `854`",
21+
optional: true,
22+
},
23+
height: {
24+
type: "integer",
25+
label: "Height",
26+
description: "The new height of the video, e.g. `480`",
27+
optional: true,
28+
},
29+
duration: {
30+
type: "integer",
31+
label: "Duration",
32+
description: "The duration to set for the video in seconds, e.g. `30`",
33+
optional: true,
34+
},
35+
transformations: {
36+
propDefinition: [
37+
cloudinary,
38+
"transformations"
39+
]
40+
},
3441
},
3542
async run({ $ }) {
36-
const response = this.resourceType === "image"
37-
? await this.cloudinary.transformImage(this.imageSource, this.options)
38-
: await this.cloudinary.transformVideo(this.videoPublicId, this.options);
43+
const { cloudinary, assetId, transformations, ...options } = this;
44+
try {
45+
const response = await cloudinary.transformAsset(assetId, {
46+
...options,
47+
...transformations,
48+
});
3949

4050
if (response) {
41-
$.export("$summary", `Successfully transformed ${this.resourceType}`);
51+
$.export("$summary", "Successfully transformed video");
4252
}
4353

4454
return response;
55+
} catch (err) {
56+
throw new Error(`Cloudinary error response: ${err.error?.message ?? JSON.stringify(err)}`);
57+
}
4558
},
4659
};

components/cloudinary/actions/upload-media-asset/upload-media-asset.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "cloudinary-upload-media-asset",
66
name: "Upload Media Asset",
77
description: "Upload media assets such as images or videos. [See the documentation](https://cloudinary.com/documentation/image_upload_api_reference#upload_method)",
8-
version: "1.0.{{ts}}",
8+
version: "1.0.0",
99
type: "action",
1010
props: {
1111
cloudinary,

components/cloudinary/cloudinary.app.mjs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@ export default {
5252
optional: true,
5353
options: constants.ACCESS_MODE_OPTIONS,
5454
},
55+
assetId: {
56+
type: "string",
57+
label: "Public ID",
58+
description: "The [public ID](https://cloudinary.com/documentation/upload_images#public_id) of the asset , e.g. `folder/filename`.",
59+
},
60+
transformations: {
61+
type: "object",
62+
label: "Additional Transformations",
63+
description: "Additional transformations to apply to the resource. [See the documentation](https://cloudinary.com/documentation/transformation_reference) for all available transformations. Example: `{ \"angle\": 90, \"color_space\": \"srgb\"}`",
64+
},
5565
},
5666
methods: {
5767
_client() {
@@ -69,12 +79,9 @@ export default {
6979
async getUsage(options) {
7080
return this._client().api.usage(options);
7181
},
72-
async transformImage(imageSource, options) {
82+
async transformAsset(imageSource, options) {
7383
return this._client().url(imageSource, options);
7484
},
75-
async transformVideo(videoPublicId, options) {
76-
return this._client().video(videoPublicId, options);
77-
},
7885
async uploadMedia(file, options) {
7986
return this._client().uploader.upload(file, options);
8087
},

0 commit comments

Comments
 (0)