jssimporter / python-jss

python-jss is deprecated. Please see the wiki for alternatives.
GNU General Public License v3.0
102 stars 41 forks source link

Don't read upload file before passing to requests #106

Closed moorereason closed 3 years ago

moorereason commented 3 years ago

While attempting to upload a package greater than 2GB to jamf with JSSImporter (via a dataJAR recipe), the following error is returned:

JSSImporter: Error: string longer than 2147483647 bytes

The fix (detailed in https://github.com/psf/requests/issues/2717#issuecomment-130343655) is to pass the file handle to requests and let requests handle the read operations.

I'm not very familiar with python-jss (buyer beware!), but changing the following two lines:

https://github.com/jssimporter/python-jss/blob/v2.1.0/jss/distribution_point.py#L661

https://github.com/jssimporter/python-jss/blob/v2.1.0/jss/distribution_point.py#L683

to:

data=resource,

resolved the issue for me.

grahampugh commented 3 years ago

So you are just changing data=resource.read(), to data=resource, ?

moorereason commented 3 years ago

Correct. I submitted a PR instead of my rather clumsy bug report.