Hi team,
I am getting the error:
at null.callAxios (/tmp/__pdg__/dist/code/21efee1458d2dfcfa11a243b4b8d16ce2e894d8573eb41d1a6ab4f8f8cad6ea2/node_modules/.pnpm/@pipedream+platform@1.5.1/node_modules/@pipedream/platform/dist/axios.js:88:24)
at Object.run (file:///tmp/__pdg__/dist/code/21efee1458d2dfcfa11a243b4b8d16ce2e894d8573eb41d1a6ab4f8f8cad6ea2/component.mjs:33:32)
at null.executeComponent (/var/task/launch_worker.js:229:53)
at MessagePort.messageHandler (/var/task/launch_worker.js:726:28)
in the following Pipedream step:
import { axios } from "@pipedream/platform";
import AWS from "aws-sdk";
export default defineComponent({
props: {
aws: {
type: "app",
app: "aws",
},
},
async run({ steps, $ }) {
const { accessKeyId, secretAccessKey } = this.aws.$auth;
const S3_BUCKET_NAME = 'pacayadigital-creativelive';
const S3_REGION = 'us-west-2';
const s3 = new AWS.S3({
accessKeyId: accessKeyId,
secretAccessKey: secretAccessKey,
region: S3_REGION,
});
const assets = steps.trigger.event.fields.Assets;
let imageData = [];
for (let i = 0; i < assets.length; i++) {
try {
let fileName = assets[i].filename.split(".")[0];
let imageKey = 'campaigns/' + fileName;
let imageUrl = assets[i].url;
console.log('URL: ', imageUrl)
const response = await axios({
method: 'GET',
url: imageUrl,
responseType: 'arraybuffer',
});
if (response.status === 200) {
const imageBuffer = response.data;
const putObjectResponse = await s3.putObject({
Bucket: S3_BUCKET_NAME,
Key: imageKey,
Body: Buffer.from(imageBuffer),
ContentType: 'image/jpeg',
}).promise();
if (putObjectResponse) {
imageData.push(imageKey);
console.log(`Image uploaded to S3: s3://${S3_BUCKET_NAME}/${imageKey}`);
} else {
console.error('Error uploading image to S3');
}
} else {
console.log('Response status: ', response.status);
console.error('Failed to download the image from the URL.');
}
} catch (error) {
console.error('[Some other error] Code is broken:', error);
}
}
for (let i = 0; i < imageData.length; i++) {
try {
const imageUrl = `https://${S3_BUCKET_NAME}.s3.${S3_REGION}.amazonaws.com/${imageData[i]}.jpg`;
console.log('Public S3 Image URL:', imageUrl);
} catch (error) {
console.error('Error retrieving public S3 URL:', error);
}
}
return imageData;
},
});
I’ve been troubleshooting this with Pi for a little while now and can’t seem to figure out what might be the issue other than it possibly being a bug?