Uploading ZIP file using API

114 views
Skip to first unread message

Rafael Segovia

unread,
Oct 18, 2024, 11:36:51 AM10/18/24
to QATrack+
Hello!

We have been using the API to upload different files (png, dcm, pdf...) to QATrack. We are now trying to upload a ZIP file (we have done it before in the web app with File Upload) using the API in a python script, but it crushes. I think it's related to the value and encode parameters, but I don't know how to solve it. If I substitute the path to the zip file for a pdf file, it works perfectly. 

'tests': {
'rt_dicom_xvi_catphan_503_zip': {
'filename': 'catphan_503.zip',
'value': base64.b64encode(open(self.zip_path, 'rb').read()).decode(),
'encoding': 'base64'
},
'rt_informe_catphan_503': {
'filename': 'informe_catphan_503.pdf',
'value': base64.b64encode(open(self.pdf_path, 'rb').read()).decode(),
'encoding': 'base64'
}
},

I could use some help!

Thank you in advance,

Rafael

Alex Bredikin

unread,
Oct 18, 2024, 11:43:30 AM10/18/24
to QATrack+
Are you getting a particular error message when it crashes? Not sure if it is related, but earlier this year I was trying to upload Catphan images (.zip file) via the API, and I was getting a returned status code of (I think) 400 - I ended up having to adjust a particular setting in IIS... I think it was maybe either maxRequestLength or maxAllowedContentLength? Sorry, my memory is foggy.

Alex

Rafael Segovia

unread,
Oct 21, 2024, 5:12:30 AM10/21/24
to Alex Bredikin, QATrack+
Hi!

Thank you for your answer. We are getting the status code 200. We have done some tests and it is related to the size of the zip file. Does anybody know how to change the limitation? Is it possible?

Thank you in advance,

Rafael

--
You received this message because you are subscribed to the Google Groups "QATrack+" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qatrack+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/qatrack/d15331ae-f242-461e-843c-ddad454f0645n%40googlegroups.com.

Alex Bredikin

unread,
Oct 21, 2024, 8:17:27 AM10/21/24
to Rafael Segovia, QATrack+

Jose Macias Jaen

unread,
Oct 24, 2024, 7:54:54 AM10/24/24
to Alex Bredikin, Rafael Segovia, QATrack+

Hello everyone,

We're encountering the same issue with uploading a ZIP file using the QATrack API. The status code returned is 500. The upload works perfectly when done manually. Does anyone know if QATrack supports file chunking or a similar option? If the API allows it, we could try uploading the file in chunks or dividing it into smaller parts for separate uploads.

Thanks!




--
José Macías Jaén
Facultativo Especialista de Área Radiofísica Hospitalaria
Hospital Universitario Virgen Macarena
Avda. Dr. Fedriani nº3 41009 Sevilla
Móvil: 679602892

Randle Taylor

unread,
Oct 30, 2024, 8:11:50 AM10/30/24
to Jose Macias Jaen, Alex Bredikin, Rafael Segovia, QATrack+
Hi,

QATrack+ does not have any chunked upload options.  If you're getting a 500 error you should be able to look in the QATrack log files and see if an exception was logged there to help diagnose the issue.  B64 encoding a file increases the size of the data significantly so it could be people are bumping into the maxRequestLength/maxAllowedContentLength that Alex pointed out, or there could be a server out of memory issue.

Rafael did you try to adjust maxRequestLength/maxAllowedContentLength?  If so, what were the results?

Randy

Rafael Segovia

unread,
Nov 4, 2024, 6:37:25 AM11/4/24
to Randle Taylor, Jose Macias Jaen, Alex Bredikin, QATrack+
Hello Randle!

Thanks for your answer. I've just found the log file with the mistake (image below). Not sure if it is related with QATrack or with our server (Linux). The parameters maxRequestLength/maxAllowedContentLength should be configured in the QATrack files or in our server?

image.png

Thank you in advance.

Regards,

Rafael

Randle Taylor

unread,
Nov 14, 2024, 9:21:03 PM11/14/24
to Rafael Segovia, Jose Macias Jaen, Alex Bredikin, QATrack+
Hi Rafael,

Sorry for the slow response.  The maxRequestLength parameter is only relevant to MSSQL so that's not the issue.  The MemoryError indicates that the server is running out of memory when trying to determine the encoding of the uploaded file.

If you are comfortable with it, you can edit the qatrack/api/qa/serializers.py file and edit the offending line from:

if not BASE64_RE.match(content):

to

if not BASE64_RE.match(content[:200]):

then restart Apache, that may reduce the memory used when determining the file encoding and allow your upload to proceed.

Randy

Rafael Segovia

unread,
Nov 19, 2024, 8:13:09 AM11/19/24
to Randle Taylor, Jose Macias Jaen, Alex Bredikin, QATrack+

Hi Randle,

There's no need to apologize. We implemented the modification you suggested, and it solved the problem! 🎉

Thank you very much for your assistance and hard work.

Best regards from Spain,

Rafa

Reply all
Reply to author
Forward
0 new messages