我使用Postman攔截來自Chrome的REST調用。我通過plupload js模塊上傳了一個文件,它似乎在用戶界面上工作正常,但在Postman或Curl中都不起作用。REST調用上傳文件以便上傳
在郵差,攔截記錄,猶如生體POST(如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
我保存在郵差截獲的POST,然後重新運行完全相同的POST,這引發了錯誤消息在我的迴應:
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
這裏是捲曲的語句從Chrome瀏覽器開發工具複製:
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
捲曲響應:
{"status":"success"}
郵差在服務器上創建一個無標題的空文件和捲曲創建具有正確名稱的文件,但它也是空的。
對於如何進行調試,您有任何建議嗎?似乎curl語句中缺少文件位置,但我在附加路徑時遇到困難-F @MOCK_DATA_20.csv