Demystifying iControl REST Part 5: Transferring Files
Hi all! This post was very helpful indeed. Also the hint with the central authentication and the requirement to upgrade to 12.1.2. However, I probably need another little hint...
When I upload a text-file (haven't tried any binary data yet) to the BigIP with the method described above, the file has a leading 0-byte.
That's the file on my management-host:
[matt@linuxhost rest_bigip]$ hexdump testfile -C
00000000 31 32 33 34 35 36 37 38 39 30 61 62 63 64 65 66 |1234567890abcdef|
00000010 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 |ghijklmnopqrstuv|
00000020 77 78 79 7a 0a |wxyz.|
00000025
after posting it to the BigIP:
[matt@linuxhost rest_bigip]$ curl -X POST https://ixi3-lab-lb2-1/mgmt/shared/file-transfer/uploads/testname.txt -H "Content-Type: application/octet-stream" -H "Content-Range: 1-36/36" -H "X-F5-Auth-Token: XXXXXXXXXXXXXX" -d @testfile -vvv
* About to connect() to ixi3-lab-lb2-1 port 443 (0)
* Trying 10.150.250.156... connected
* Connected to ixi3-lab-lb2-1 (10.150.250.156) port 443 (0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
* CAfile: xxxx
CApath: none
* SSL connection using TLS_RSA_WITH_AES_128_CBC_SHA
* Server certificate:
* xxxxxx
> POST /mgmt/shared/file-transfer/uploads/testname.txt HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.19.1 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: ixi3-lab-lb2-1
> Accept: */*
> Content-Type: application/octet-stream
> Content-Range: 1-36/36
> X-F5-Auth-Token: XXXXXXXXXXXXXX
> Content-Length: 36
>
< HTTP/1.1 200 OK
< Date: 15 Feb 2017 15:21:20 UTC
< Server: com.f5.rest.common.RestRequestSender
< X-Frame-Options: SAMEORIGIN
< Strict-Transport-Security: max-age=16070400; includeSubDomains
< Pragma: no-cache
< Cache-Control: no-store, no-cache, must-revalidate
< Expires: -1
< Content-Length: 241
< Content-Type: application/json
< Content-Range: 1-36/36
< Local-Ip-From-Httpd: 10.150.250.156
< X-Forwarded-Server: localhost.localdomain
< X-Forwarded-Proto: http
< X-Forwarded-Host: ixi3-lab-lb2-1
< X-Content-Type-Options: nosniff
< X-XSS-Protection: 1; mode=block
< Content-Security-Policy: default-src 'self' 'unsafe-inline' 'unsafe-eval'; img-src 'self' http://127.4.1.1 http://127.4.2.1
<
* Connection 0 to host ixi3-lab-lb2-1 left intact
* Closing connection 0
{"remainingByteCount":0,"usedChunks":{"1":36},"totalByteCount":36,"localFilePath":"/var/config/rest/downloads/testname.txt","temporaryFilePath":"/var/config/rest/downloads/tmp/testname.txt","generation":0,"lastUpdateMicros":1487172080246573}
The file on the BigIP does not look quite the same (note byte 0 being 0x00, as opposed to 0x31 in the original file):
[matt@ixi3-lab-lb2-1:Active:Standalone] ~ xxd /var/config/rest/downloads/testname.txt
0000000: 0031 3233 3435 3637 3839 3061 6263 6465 .1234567890abcde
0000010: 6667 6869 6a6b 6c6d 6e6f 7071 7273 7475 fghijklmnopqrstu
0000020: 7677 7879 7a vwxyz
Also the original "\n" seems to be trimmed off, which isn't a problem in this case. Just mentioning it for the sake of completeness. I tried to use Content-Type: text/plain instead of "application/octet-stream", I tried binary-transfer, nothing seems to help. What am I missing here? Thanks for your help!
regards, Matt
update:
trace-ascii shows that curl seems to be sending the post data correctly
=> Send data, 36 bytes (0x24)
0000: 1234567890abcdefghijklmnopqrstuvwxyz
<= Recv header, 17 bytes (0x11)
0000: HTTP/1.1 200 OK