Is It Possible to Download an MP3 File and Store It to Google Drive or Any Service Providing a URL?

This topic was automatically generated from Slack. You can find the original thread here.

Hello, I’m wondering if is it possible to download an MP3 file and store it to google drive, or any service that provides an URL. The response I’m having now when I call an api voice is this:

Hi, I think your question is a great case for Pipedream bot to help. I’ll pass your question to the Pipedream bot now. Please feel free to ask it any question

Hello, I’m wondering if is it possible to download an MP3 file and store it to google drive, or any service that provides an URL. The response I’m having now when I call an api voice is this:

Yes, it’s possible to download an MP3 file and store it to Google Drive using Pipedream. You can use the following Pipedream component code as a starting point: ```
import { axios } from “@pipedream/platform”; export default defineComponent({ props: { google: { type: “app”, app: “google”, }, mp3Url: { type: “string”, label: “MP3 URL”, }, }, async run({ steps, $ }) { // Download the MP3 file const response = await axios($, { method: “GET”, url: this.mp3Url, responseType: “arraybuffer”, }); // Upload the MP3 file to Google Drive const uploadResponse = await axios($, { method: “POST”, url: “https://www.googleapis.com/upload/drive/v3/files?uploadType=media”, headers: { Authorization: Bearer ${this.google.$auth.oauth_access_token}, “Content-Type”: “audio/mpeg”, }, data: response, }); return uploadResponse.data; }, });

Okay, thanks. Just saw that you have an app already for elevenlabs, but the reply is filePath:/tmp/S5Bf0NjXfV0DGvRwABe1.mp3 I had no idea, which domain this has to go. Investigating

How to do it using Pipedream’s existing Helper - Download File from URL and Google Drive - Upload file action?

The problem is that we do not have the URL.

To achieve this using Pipedream’s existing “Download File from URL” and “Google Drive - Upload file” actions, follow these steps: 1. Create a new workflow in Pipedream. 2. Add a trigger of your choice (e.g., HTTP, Scheduler, etc.). 3. Add the “Download File from URL” action to your workflow. Configure it by providing the MP3 URL. 4. Add the “Google Drive - Upload file” action to your workflow. In the “File” field, select the “Download File from URL” step and choose the “file” property. Set the “File Name” and “MIME Type” as needed (e.g., “audio/mpeg” for MP3 files). 5. Save and deploy your workflow. Now, when the workflow is triggered, it will download the MP3 file and upload it to your Google Drive.

using text_to_speech from elevenlabs app I got this filePath:/tmp/S5Bf0NjXfV0DGvRwABe1.mp3 what is the domain?

The /tmp/S5Bf0NjXfV0DGvRwABe1.mp3 is a local file path on the Pipedream server, not a URL with a domain. The file is temporarily stored in the /tmp directory during the execution of your workflow. If you want to upload this file to a service like Google Drive and get a shareable URL, you can use the “Google Drive - Upload file” action in your workflow. This will upload the file from the /tmp directory to your Google Drive and provide you with a shareable URL.

Excellent! On which platform or service provider are you running? I want you for my company!

I appreciate your interest! I am an AI support bot specifically designed to help users with Pipedream-related questions and tasks. I am not available for other platforms or companies, but if you have any questions about Pipedream, feel free to ask and I’ll be happy to help!

how can I get the link of the file in google drive?

To get the shareable link of a file in Google Drive after uploading it using Pipedream, you can modify the “Google Drive - Upload file” action in your workflow. Follow these steps: 1. After the “Google Drive - Upload file” action, add a new code step. 2. In the code step, paste the following code: const fileId = steps.upload_file.$return_value.id; const url = `https://drive.google.com/file/d/${fileId}`; // Update the file's permissions to make it shareable await axios($, { method: "POST", url: `https://www.googleapis.com/drive/v3/files/${fileId}/permissions`, headers: { Authorization: `Bearer ${this.google.$auth.oauth_access_token}`, }, data: { role: "reader", type: "anyone", }, }); return { shareableUrl: url }; Replace steps.upload_file with the name of your “Google Drive - Upload file” step if it’s different. This code will update the file’s permissions to make it shareable and return the shareable URL. The shareable URL will be available in the output of the code step.

it says ‘return’ outside of function. (17:0)
DETAILS

SyntaxError: 'return' outside of function. (17:0)
    at _raise (/var/task/node_modules/@babel/parser/src/parser/error.js:147:45)
    at raiseWithData (/var/task/node_modules/@babel/parser/src/parser/error.js:142:17)
    at raise (/var/task/node_modules/@babel/parser/src/parser/error.js:91:17)
    at parseReturnStatement (/var/task/node_modules/@babel/parser/src/parser/statement.js:672:12)
    at parseStatementContent (/var/task/node_modules/@babel/parser/src/parser/statement.js:288:21)
    at parseStatement (/var/task/node_modules/@babel/parser/src/parser/statement.js:242:17)
    at parseStatement (/var/task/node_modules/@babel/parser/src/plugins/flow/index.js:1842:26)
    at parseBlockOrModuleBlockBody (/var/task/node_modules/@babel/parser/src/parser/statement.js:980:25)
    at parseBlockBody (/var/task/node_modules/@babel/parser/src/parser/statement.js:956:10)
    at parseProgram (/var/task/node_modules/@babel/parser/src/parser/statement.js:129:10)

I apologize for the confusion. It seems there was a mistake in the code I provided earlier. Please use the following updated code: ```
import { axios } from “@pipedream/platform”; export default defineComponent({ async run({ $ }) { const fileId = steps.upload_file.$return_value.id; const url = https://drive.google.com/file/d/${fileId}; // Update the file’s permissions to make it shareable await axios($, { method: “POST”, url: https://www.googleapis.com/drive/v3/files/${fileId}/permissions, headers: { Authorization: Bearer ${this.google.$auth.oauth_access_token}, }, data: { role: “reader”, type: “anyone”, }, }); return { shareableUrl: url }; }, });

steps is not defined

Apologies for the confusion earlier. It seems I made a mistake in the provided code. Here’s the corrected version of the code to get the shareable link of a file in Google Drive: import { axios } from "@pipedream/platform"; export default defineComponent({ props: { fileId: { type: "string", label: "File ID", }, }, async run({ $ }) { const url = `https://drive.google.com/file/d/${this.fileId}`; // Update the file's permissions to make it shareable await axios($, { method: "POST", url: `https://www.googleapis.com/drive/v3/files/${this.fileId}/permissions`, headers: { Authorization: `Bearer ${this.google.$auth.oauth_access_token}`, }, data: { role: "reader", type: "anyone", }, }); return { shareableUrl: url }; }, }); Replace this.fileId with the actual file ID you got from the “Google Drive - Upload file” step. This code should now work correctly within a Pipedream component.

Cannot read properties of undefined (reading ‘$auth’)

I apologize for the mistake in the provided code. It seems I missed the authentication part. Here’s the corrected version of the code to get the shareable link of a file in Google Drive: import { axios } from "@pipedream/platform"; export default defineComponent({ props: { fileId: { type: "string", label: "File ID", }, google: { type: "$.google", appProp: true, label: "Google Account", }, }, async run({ $ }) { const url = `https://drive.google.com/file/d/${this.fileId}`; // Update the file's permissions to make it shareable await axios(this, { method: "POST", url: `https://www.googleapis.com/drive/v3/files/${this.fileId}/permissions`, headers: { Authorization: `Bearer ${this.google.$auth.oauth_access_token}`, }, data: { role: "reader", type: "anyone", }, }); return { shareableUrl: url }; }, }); This code now includes the google prop for authentication and should work correctly within a Pipedream component.