So what you could potentially do is use the Custom RingCentral API request with Node.js and download the file and store it to /tmp or a File Store in the same code step
Yeah I think that’s a good work around. I’ll try that and report back. Thank you for helping me troubleshoot
Oh and one final question, is there any documentation around using my RingCentral auth in Node like that?
Yes, here’s the main docs on how to use connected accounts with any app in Pipedream Node.js steps:
Perfect thank you
Sure thing. Hope this helps.
Also, it might help to test by uploading the file to the File Store for your project:
Since it doesn’t require auth or Google Drive’s special metafields props, it’ll help you test to make sure that the downloaded version is exactly the same
Good idea! I’ll give it a shot
Hey Pierce, just reporting back here with my findings. I finally did get it to work. Here’s the complete final working code for reference
import { axios } from "@pipedream/platform"
import fs from "fs";
export default defineComponent({
props: {
ringcentral: {
type: "app",
app: "ringcentral",
},
url: {
type: "string",
label: "Download File URL",
description: "Enter the URL of the file to download",
},
filename: {
type: "string",
label: "Target Filename",
description: "The filename that will be used to save in /tmp",
},
},
async run({ steps, $ }) {
const {
url, filename,
} = this;
var result = await axios($, {
url: url,
headers: {
Authorization: `Bearer ${this.ringcentral.$auth.oauth_access_token}`,
},
responseType: 'arraybuffer',
returnFullResponse: true
})
const rawcontent = result.data.toString("base64");
const buffer = Buffer.from(rawcontent, "base64");
const downloadedFilepath = `/tmp/${filename}`;
fs.writeFileSync(downloadedFilepath, buffer);
const filedata = {
filename,
downloadedFilepath,
};
return filedata;
}
});
const rawcontent = result.data.toString("base64");
const buffer = Buffer.from(rawcontent, "base64");
const downloadedFilepath = `/tmp/${filename}`;
fs.writeFileSync(downloadedFilepath, buffer);
specifically calling out these lines here. I had to convert the file to a base64 string, then turn that into a buffer, and then when I store that in tmp file storage it is stored correctly and I’m able to upload it to google drive and it’s not corrupted.
Awesome! So glad you were able to figure that out Kyle. That’s fantastic.
Hopefully this opens some doors for you to automate more for your team.
Definitely does!