Closed AgustinQuetto closed 4 years ago
Does user have a google drive integration for any chance? I think it’s better that you contact suppport that can trace the request
Google Drive is not integrated. I have the images in S3, I download them locally to upload them to Pipedrive. The file is local when it is uploaded and even if it is done with a "pre-created" one, without the previous download, the process is the same. It's usually happening with PDF files more frequently. With the images it does not usually happen. Thank you!
@tot-ra how or where can I contact support for this issue? 🤔
I think I found the problem. At some point the bearer's token becomes undefined. I made a console.log of the context and the response sent appears like this. The strange thing is that it is a linear process where before a client update, deal and some file uploads are made. It seems that the problem arises when more than one load is done at the same time.
More debugs... oAuth is missing and undefined. I'm using the api token.
It seems to be no problem. It is not listed in deals authorization. In the files I removed it and the behavior is the same.
Now I have opted to use the API directly and I have no problem uploading files. I'm going to have to continue using this method without going through the library.
If I can help fix it, let me know.
Hi @AgustinQuetto
I did not succeed in reproducing this issue. This is how I've tried it
const Pipedrive = require('pipedrive'); // latest Pipedrive Node.js
const path = require('path');
const API_TOKEN = '<API-TOKEN>'; // replace to yours
const DEAL_ID = '<DEAL_ID>'; // replace to yours
Pipedrive.Configuration.apiToken = API_TOKEN;
function dealFileUpload(filePath) {
return new Promise((resolve, reject) => {
const input = {
file: filePath,
deal_id: DEAL_ID,
};
Pipedrive.FilesController.addFile(input, (err, res) => {
if (err) {
reject(err)
} else {
resolve(res);
}
})
});
}
async function testIssue() {
try {
const imgLocalFile = path.resolve(__dirname, 'file.png'); // less than 1mb
const pdfLocalFile = path.resolve(__dirname, 'file.pdf'); // less than 1mb
const pdfBigLocalFile = path.resolve(__dirname, 'file_big.pdf'); // ~6mb
const pdfRemoteFile = 'https://<domain>/file.pdf'; // link to remote file
const resultImgLocal = await dealFileUpload(imgLocalFile); // - works as expected
const resultPdfLocal = await dealFileUpload(pdfLocalFile); // - works as expected
const resultPdBigfLocal = await dealFileUpload(pdfBigLocalFile); // - works as expected
// const resultPdRemote = await dealFileUpload(pdfRemoteFile); // - does not work with links
} catch (err) {
console.log('err', err);
}
}
testIssue()
I've tested it with local files (file.pdf, file.png are local files on my computer), everything works. If I try to upload a file by link, the upload will fail.
Could you provide a bit more information about:
pathImage
variable you used in the last example (I mean, is it a path to a local file, Buffer, or URL).getImageS3(url)
function. What it does/returns (as I understood it's some wrapper around AWS S3)node -v
Thank you
Hi! It's a local path file. getImageS3 just return the local path where the file was saved.
Node version: 12.14.1
I decided to directly use the endpoint for the upload and it works perfectly. Maybe the lib has some problem when uploading multiple files in parallel and promises are resolved with .all It is the only factor that I found since with the direct endpoint it works wonderfully. What I don't like about the new lib is that it is not instantiable and is somewhat annoying when handling multiple clients and different concurrent tokens. If you like, I could abstract the code that was having problems and upload it to a gist.
Hi!
I could abstract the code that was having problems and upload it to a gist
That's a really good idea. It would really help to understand the issue you're having.
This issue will be closed for now as it was not possible to reproduce this behaviour. Feel free to re-open it once there is a code example that can be used to reproduce it.
Hello! I'm uploading files to a deal in Pipedrive and "randomly" the api responds with error 400. Sometimes it uploads well, sometimes uploads poorly. The file is the same and is in a path. Do you know if there is any limit between file uploads?
And noteId or note_id doesn't work, apparently.