Image URL to be posted as multipart-formdata to an endpoint?

Tried implementing file upload to tmp and it don’t gave any result.(Attached screenshot)

I wanted to post a image from url to another endpoint for results.

How my endpoint look like:
https://api-2445582032290.production.gw.apicast.io/v1/foodrecognition/full?user_key=123456789
Parameter type: formData

Hi @athul.sreenivasan,

To upload an image from the /tmp directory to an API using multipart/form-data in Pipedream, you can use the form-data package along with the axios package from @pipedream/platform. Here’s an example of how to do this:

import { axios } from "@pipedream/platform";
import FormData from "form-data";
import fs from "fs";

export default defineComponent({
  async run({ $ }) {
    // Replace with the path to your image file in the /tmp directory
    const imagePath = "/tmp/your-image-file.jpg";

    // Replace with the target API URL
    const apiUrl = "https://your-api-url.com/upload";

    // Create a new FormData instance
    const formData = new FormData();

    // Append the image file to the form data
    formData.append("image", fs.createReadStream(imagePath));

    // Get the form data headers
    const headers = formData.getHeaders();

    // Send the request using axios
    const response = await axios($, {
      method: "POST",
      url: apiUrl,
      data: formData,
      headers: headers,
    });

    // Return the response data
    return response;
  },
});

Make sure to replace your-image-file.jpg with the actual image file name in the /tmp directory and https://your-api-url.com/upload with the target API URL. This code will upload the image file using multipart/form-data to the specified API.

which part of the workflow or code should i authenticate the API with token?

My api look like:

https://api-2445582032290.production.gw.apicast.io/v1/foodrecognition/full?user_key=123456789

Where (user_key) is the token to authenticate

Also does this code snippet should go after my node code or just this works?

It’s the apiUrl that you need to change to add the token. I believe your code snippet is not working as a Pipedream component

I think this need a sufficient coding knowledge to implement. If you’re still unsure that you can implement your usecase, you can:

  1. Read more about Pipedream Node.js document here
  2. Read more about Javascript, especially Node.js part. Also you can watch through Pipedream speedrun series to have more references
  3. Submit a ticket for Pipedream, stating the action on the app that you need
  4. If you have subscribed to Pipedream team plan, you will be added to a dedicated slack support channel
  5. If you’d like to hire a Pipedream expert for your usecase, feel free to use this link: Connect with a Pipedream Partner