Skip to content

Commit d9a54c5

Browse files
committed
File upload improvements
1 parent b474087 commit d9a54c5

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import cloudinary from "../../cloudinary.app.mjs";
2+
import fs from 'fs';
23

34
export default {
45
key: "cloudinary-upload-media-asset",
@@ -74,11 +75,6 @@ export default {
7475
},
7576
},
7677
async run({ $ }) {
77-
let file = this.file;
78-
if (typeof file === 'string' && file.match(/^\/?tmp/)) {
79-
file = fs.createReadStream(file);
80-
}
81-
8278
const options = {
8379
public_id: this.publicId,
8480
folder: this.folder,
@@ -98,12 +94,12 @@ export default {
9894
};
9995

10096
try {
101-
const response = await this.cloudinary.uploadMedia(file, options);
97+
const response = await this.cloudinary.uploadMedia(this.file, options);
10298
if (response) {
10399
$.export("$summary", "Successfully uploaded media asset");
104100
}
105101
return response;
106-
} catch (e) {
102+
} catch (err) {
107103
throw new Error(`Cloudinary error response: ${err.error?.message ?? JSON.stringify(err)}`);
108104
}
109105
},

0 commit comments

Comments
 (0)