zenpy icon indicating copy to clipboard operation
zenpy copied to clipboard

Issue with macro attachments upload

Open ypperlig opened this issue 5 years ago • 2 comments

Hi, Unfortunate that my previous PR broke attachment uploads, was not my intention.

I have not been able to get macro attachments to work consistently after headers were re-introduced in https://github.com/facetoe/zenpy/commit/983af277eed647e56b687cd3d9018570aad8d8b0.

I have tested this, and not been able to make it work with the current implementation of macro attachments, so MacroApi.upload_attachment is currently broken.

I haven't had the time to test the differences between how requests operates without content-type set, but setting content type to content_type="multipart/form-data; boundary=something" does not work.

ypperlig avatar Jan 16 '20 11:01 ypperlig

All good, I've reverted that code for now. I think once we know what is up we should add a new upload request handler for the macro uploads. The existing upload one is getting a bit complex.

facetoe avatar Jan 19 '20 03:01 facetoe

The issue here seems to come from requests ignoring setting content-type if content-type is already specified. Once they have encoded the body, the header will be incorrect as it's missing the boundary requests has used during encoding of the data.

I think adding an upload handler specific for MacroAttachments would be ideal as you say, to keep it less complex while also not breaking anything 👍

ypperlig avatar Jan 24 '20 21:01 ypperlig