I'm using Postman to intercept the REST calls from Chrome. I'm uploading a file through the plupload js module and it seems to work fine from the UI but doesn't work in either Postman or curl.
In Postman, the interceptor records it as a POST with a raw body (e.g. data.txt)
------WebKitFormBoundarycatLhfxNDVGW02wa
Content-Disposition: form-data; name="name"
MOCK_DATA_100.csv
------WebKitFormBoundarycatLhfxNDVGW02wa
Content-Disposition: form-data; name="chunk"
0
------WebKitFormBoundarycatLhfxNDVGW02wa
Content-Disposition: form-data; name="chunks"
1
------WebKitFormBoundarycatLhfxNDVGW02wa
Content-Disposition: form-data; name="filename"
MOCK_DATA_100.csv
------WebKitFormBoundarycatLhfxNDVGW02wa
Content-Disposition: form-data; name="file"; filename="MOCK_DATA_100.csv"
Content-Type: application/vnd.ms-excel
I saved the intercepted POST in Postman and then reran the exact same POST and this threw an error message in my response:
Sorry, our system is experiencing a problem.
<br />(Error code 0)
<br />Error "The file "MOCK_DATA_100.csv" was only partially uploaded."
occurred at line 251 of
../Symfony/Component/HttpFoundation/File/UploadedFile.php
Here is the curl statement copied from chrome dev tools:
curl -k 'https://localhost/api/v1/user-contact-data/file' \
-H 'Pragma: no-cache' -H 'Origin: https://localhost' \
-H 'Accept-Encoding: gzip, deflate' \
-H 'Accept-Language: en-US,en;q=0.8' \
-H 'User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.109 Safari/537.36' \
-H 'Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryBQR6SxZD8udgj5et' \
-H 'Accept: */*' \
-H 'Cache-Control: no-cache' \
-H 'Referer: https://localhost' \
-H 'Cookie: WBSESSID=XXXjaaqdv3g6sp3k4729fb9ibq5057p3uviib3v1ba7dd8juhvk9bm6ttv360npp8qioi9a25vs3nmra9t9l7ki43og38jb7sl3bXXX; fileName=MOCK_DATA_100.csv' \
-H 'Connection: keep-alive' \
-H 'DNT: 1' --data-binary $'------WebKitFormBoundaryBQR6SxZD8udgj5et\r\nContent-Disposition: form-data; name="name"\r\n\r\nMOCK_DATA_100.csv\r\n------WebKitFormBoundaryBQR6SxZD8udgj5et\r\nContent-Disposition: form-data; name="chunk"\r\n\r\n0\r\n------WebKitFormBoundaryBQR6SxZD8udgj5et\r\nContent-Disposition: form-data; name="chunks"\r\n\r\n1\r\n------WebKitFormBoundaryBQR6SxZD8udgj5et\r\nContent-Disposition: form-data; name="filename"\r\n\r\nMOCK_DATA_100.csv\r\n------WebKitFormBoundaryBQR6SxZD8udgj5et\r\nContent-Disposition: form-data; name="file"; filename="MOCK_DATA_100.csv"\r\nContent-Type: application/vnd.ms-excel\r\n\r\n\r\n------WebKitFormBoundaryBQR6SxZD8udgj5et--\r\n' \
--compressed
curl response:
{"status":"success"}
Postman creates an untitled empty file on the server and curl creates the file with the correct name but it's also empty.
Do you have any advice on how to debug this? It seems that the file location is missing from the curl statement but I'm having difficulty attaching the path with -F @MOCK_DATA_20.csv