API file uploads getting corrupted

API file uploads getting corrupted

seth_k
Explorer Explorer
509 Views
1 Reply
Message 1 of 2

API file uploads getting corrupted

seth_k
Explorer
Explorer

Hi - I'm running into an issue with uploading files via the v3 API.

 

In my case, I am uploading four files: a PDF, a STEP, a ZIP, and an XLSX file. All four file types upload successfully without any issues, but the STEP and XLSX files are not viewable online (corruption error). The PDF views fine online and of course the ZIP document type is not preview-able. If I download all four files, the PDF and ZIP appear fine but the STEP and XLSX files are corrupted locally too.

 

When I open the STEP file in a text editor, I see the following header and tail added:

--2b221a37d08d48edb168518e4c1c83cb
Content-Disposition: form-data; name="file"; filename="FILENAME.STEP"

 

CONTENT

 

--2b221a37d08d48edb168518e4c1c83cb--

 

If I delete the extra text, the STEP file is fine. This sounds like a header or other data handling issue, but I've tried examining the API calls in Chrome via F-12 and can't find the clues I am looking for. Any advice?

0 Likes
510 Views
1 Reply
Reply (1)
Message 2 of 2

seth_k
Explorer
Explorer

Problem solved. For anyone else running into this issue with Python requests library...

 

My problem was using requests.put with 'files = ' option instead of 'data = ' option. The seemed to work for binary files but not text based files (well it worked, but added the header and footer to the uploaded text per my original post'. After switching to 'data=' the problem appears to be resolved.

 

0 Likes