How do I get Cloudmersive to see a file in a Dropbox directory

I have run into a small dilemma, I use Dropbox as a trigger to execute my workflow. It listens for a new file with an .xlsx file extension, and executes another step to a Cloudmersive api call to convert the file to a .csv file.

The trigger works great and the call in Cloudmersive works great, but apparently Cloudmersive can’t determine the location of the file from the Dropbox trigger.

Code that runs, and the result.


var fs = require(‘fs’)
var CloudmersiveConvertApiClient = require(‘cloudmersive-convert-api-client’);
var defaultClient = CloudmersiveConvertApiClient.ApiClient.instance;

// Configure API key authorization: Apikey
var Apikey = defaultClient.authentications[‘Apikey’];
Apikey.apiKey = ‘I Place my key here…’;

var apiInstance = new CloudmersiveConvertApiClient.ConvertDocumentApi();
// HERE’S THE REFERENCE TO FILE
var inputFile = Buffer.from(fs.readFileSync( steps.trigger.event.path_lower ).buffer);
// File | Input file to perform the operation on.

var opts = {
‘outputEncoding’: “outputEncoding_example” // String | Optional, set the output text encoding for the result; possible values are UTF-8, ASCII and UTF-32. Default is UTF-8.
};

var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ’ + data);
}

};
apiInstance.convertDocumentXlsxToCsv(inputFile, opts, callback);

Error ENOENT: no such file or directory, open ‘/invoicedatafiles/expenses06-04-21.xlsx’


Is there a prefix to identify the location of the file in the Dropbox folder?

Thanks,

Scott.

Hi Scott,

The ENOENT is actually being returned from fs.readFileSync. That function has to read a local file path, and doesn’t know how to fetch a remote file from Dropbox (the steps.trigger.event.path_lower reference you’re passing).

I believe you’ll first need to download the file contents from Dropbox and save it as a file to the /tmp directory on Pipedream. You have full access to /tmp within Pipedream workflows, so you can read and write any files you’d like there.

Once you save the Dropbox file to /tmp, you should be able to read that file and pass it to the Cloudmersive API client:

var inputFile = Buffer.from(fs.readFileSync("/tmp/your-file-here").buffer);

Let me know if that helps.

Thanks Dylan for your quick response. I’ll give this a try and get back to you.