This topic was automatically generated from Slack. You can find the original thread here.
Hey y’all et - can someone take a look at this URL and see if it’s compatible with axios? I am getting an error when I try to access it and pass to S3.
Error message:
Error uploading image to S3: at Object.run (file:///tmp/__pdg__/dist/code/e63c423422c361612faaabcb20dab3931c62c048d33286218648ec19d8641c50/component.mjs:38:21)
at null.executeComponent (/var/task/launch_worker.js:229:53)
at MessagePort.messageHandler (/var/task/launch_worker.js:726:28)
I’m sorry to hear that you’re having trouble with the URL and axios. To help you better, I’ll need to see the code you’re using to make the request and upload the file to S3. Could you please share the relevant code snippet? This will help me understand the issue and provide a solution.
I see that you’re trying to download images from URLs and upload them to an S3 bucket. I noticed a few issues in your code related to the use of HTML entities and arrow functions. Here’s the corrected version of your code: ``` 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 imageData = []; const assets = steps.trigger.event.fields.Assets; 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; // Download the image from the URL using axios await axios.get(imageUrl, { responseType: ‘arraybuffer’ }) .then((response) => { // Check if the download was successful if (response.status === 200) { // Upload the downloaded image to S3 s3.putObject({ Bucket: S3_BUCKET_NAME, Key: imageKey, Body: response.data, ContentType: ‘image/jpeg’, }, (err, data) => { if (err) { console.error(‘[putObject] Error uploading image to S3:’, err); } else { console.log(Image uploaded to S3: s3://${S3_BUCKET_NAME}/${imageKey}); } }); } else { console.error(‘Failed to download the image from the URL.’); } }) .catch((error) => { console.error(‘[Inner] Error downloading image from URL:’, error); }); } catch (error) { console.error(‘[Outer] Error uploading image to S3:’, error); } } for (let i = 0; i < imageData.length; i
this code is still resulting in the error “[Outer] Error uploading image to S3: at Object.run (file:///tmp/pdg/dist/code/4e788acb516af5067aad8644d6187ff09df71a600b23f296874320e5dcae4cd8/component.mjs:27:20)
at null.executeComponent (/var/task/launch_worker.js:229:53)
at MessagePort.messageHandler (/var/task/launch_worker.js:726:28)” being logged to the console