Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File upload breaks with binary files #50

Closed
scottsbaldwin opened this issue Jun 6, 2017 · 3 comments · Fixed by #105
Closed

File upload breaks with binary files #50

scottsbaldwin opened this issue Jun 6, 2017 · 3 comments · Fixed by #105
Labels

Comments

@scottsbaldwin
Copy link

When I use the JavaScript client to upload a binary file to a deal, the file gets corrupted. I see that issue #5 (which is closed) explains a fix was to use the file_path property. However, this only works for plain text files for me. When I use a binary file, I get the behavior that @alexandremaeda mentioned in #5.

Ultimately, I had to bypass using the JavaScript client completely and go straight to the API. I looked at how the Pipedrive web app did file uploads and saw that it used the form-data library. The gist below shows my solution using form-data. Because this solution deviates from the typical pattern in the JavaScript client for sending requests to the API, I did not create a pull request.

https://gist.github.com/scottsbaldwin/230465d8d90c9e05b37535dbc723c7ac

Could something like this be adapted to work in the API?

@HriBB
Copy link

HriBB commented Nov 29, 2017

@scottsbaldwin I am having the same issue. Thanks for the solution ;)

Would be nice if API supported uploading binary files though ...

@tot-ra tot-ra added the bug label Mar 29, 2018
@tot-ra
Copy link
Contributor

tot-ra commented Mar 31, 2018

I can confirm that uploading binary file (like image) through this library technically goes through

				client.Files.add({
						deal_id: 52,
						file_path: __dirname + '/logo.png',
					}, function (err, data) {
						console.log(err);
						console.log(data);
					});

.. but result in UI is not viewable and compared to uploading same file through UI, they differ in filesize. Apparently the problem is in how data is embedded into multipart handler and how content-length is calculated

screen shot 2018-03-31 at 19 45 34

@celso
Copy link

celso commented Aug 24, 2018

I have this problem too. Any update?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants