Is it Possible to Send an Image to an API Directly from Google Drive or Does It Require Storage in /tmp First for PipeDream to Facilitiate the Process?

I apologize for the inconvenience you’re facing. It appears that the response data is undefined, which might be due to an incorrect file ID or issues with the Google Drive API. To help you further, please double-check the file ID you’re using and ensure that it’s correct and accessible. If the issue persists, please provide more information about the file you’re trying to access and any error messages you might be encountering.

the file is referenced from the trigger step. The variable is: {{steps.trigger.event.id}} and the file ID is 1os0eonZV8sUS1Ko3pX9_FIxB5p5xJwkC. I have checked it, and this file ID is correct. It is a PNG image hosted in a Google Drive that I have connected to PipeDream

Thank you for providing the file ID and additional information. Since you’ve confirmed that the file ID is correct, let’s modify the component code to use steps.trigger.event.id instead of this.fileId. Here’s the updated code: ```
import { axios } from “@pipedream/platform”; import FormData from “form-data”; export default defineComponent({ props: { google: { type: “app”, app: “google”, }, stabilityApiKey: { type: “string”, label: “Stability.ai API Key”, description: “Your Stability.ai API key”, }, }, async run({ steps, $ }) { const fileId = steps.trigger.event.id; const response = await axios($, { url: https://www.googleapis.com/drive/v3/files/${fileId}?alt=media, headers: { Authorization: Bearer ${this.google.$auth.oauth_access_token}, }, responseType: “arraybuffer”, }); if (response.data) { const formData = new FormData(); formData.append(“image”, Buffer.from(response.data), “image.png”); formData.append(“height”, 0); const stabilityApiUrl = “https://api.stability.ai/v1/generation/esrgan-v1-x2plus/image-to-image/upscale”; return await axios($, { method: “POST”, url: stabilityApiUrl, headers: { …formData.getHeaders(), Accept: “application/json”, Authorization: Bearer ${this.stabilityApiKey}, }, data: formData, }); } else { throw new Error(“The response data is undefined. Please check the file ID and try again.”); } }, });

Error:

    at Object.run (file:///tmp/__pdg__/dist/code/3e1926f4efd7220b570f5c76a6c4c188c473c1aa11de2497b02b2636a1adfc52/component.mjs:45:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at null.executeComponent (/var/task/launch_worker.js:229:22)
    at MessagePort.messageHandler (/var/task/launch_worker.js:726:28)

I apologize for the inconvenience you’re experiencing. To better understand the issue, could you please provide more context about the workflow and the specific step where this error is occurring? This will help me identify the problem and provide a solution.

import { axios } from@pipedream/platform”;
import FormData from “form-data”;

export default defineComponent({
props: {
google: {
type: “app”,
app: “google”,
},
stabilityApiKey: {
type: “string”,
label: “Stability.ai API Key”,
description: “Your Stability.ai API key”,
},
},
async run({ steps, $ }) {
const fileId = steps.trigger.event.id;

**const** response = **await** axios($, {
  url: `https://www.googleapis.com/drive/v3/files/${fileId}?alt=media`,
  headers: {
    Authorization: `Bearer ${**this**.google.$auth.oauth_access_token}`,
  },
  responseType: "arraybuffer",
});

**if** (response.data) {
  **const** formData = **new** FormData();
  formData.append("image", Buffer.**from**(response.data), "image.png");
  formData.append("height", 0);

  **const** stabilityApiUrl = "https://api.stability.ai/v1/generation/esrgan-v1-x2plus/image-to-image/upscale";

  **return** **await** axios($, {
    method: "POST",
    url: stabilityApiUrl,
    headers: {
      ...formData.getHeaders(),
      Accept: "application/json",
      Authorization: `Bearer ${**this**.stabilityApiKey}`,
    },
    data: formData,
  });
} **else** {
  **throw** **new** Error("The response data is undefined. Please check the file ID and try again.");
}

},
});

Error:

    at Object.run (file:///tmp/__pdg__/dist/code/3e1926f4efd7220b570f5c76a6c4c188c473c1aa11de2497b02b2636a1adfc52/component.mjs:45:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at null.executeComponent (/var/task/launch_worker.js:229:22)
    at MessagePort.messageHandler (/var/task/launch_worker.js:726:28)