xillio/xill-platform

File upload to Drupal succeeds but the file contents are empty

Opened this issue · 2 comments

Freshdesk Ticket ID: 1941
Freshdesk Ticket Agent: Xavier Pardonnet
Freshdesk Ticket Agent Email: xavier.pardonnet@xillio.com
Ticket Priority: Low
Freshdesk Ticket Description:

Issue: file upload using XURL.post succeeds but the file contents are empty. Executing the same post, both with Postmand and CURL the post succeeds and the file contents are not empty as expected.

Below the post that is executed. The body directly contains the binary content of a file. In Xill this is done by setting the body to the result of File.openRead(path).

POST /file/upload/media/document/field_media_document?_format=json HTTP/1.1
Host: rivm-drpc1-l01p.rivm.ssc-campus.nl
X-CSRF-Token: secrettoken
Content-Disposition: file;filename="something.pdf"
Content-Type: application/octet-stream
Authorization: Basic secret=

Post example in CURL:

curl -X POST "http://www.blaat.nl/file/upload/media/document/field_media_document?_format=json" -H "Authorization: Basic secret=" -H "Cache-Control: no-cache" -H "Content-Disposition: file;filename=\"something.pdf\"" -H "Content-Type: application/octet-stream" -H "X-CSRF-Token: secret" --data-binary @"D:/migrationdata/bin/16b475e3-41c7-4b48-be58-4331acdcb5a6-4-main-703717008.pdf"

We suspect that this relates to #12

If this is the case, a solution might be to add an optional "suppress automatic headers" flag, with default value false. Not sure if Xill allows for something like that, but that would make it possible to not have such headers included and manually set them/override them if needed, but it would not break compatibility for existing scripts.