I have written an Application, should upload some files to several mobile devices. By now, I am using dropbox, I have an App (https://www.dropbox.com/developers), so I can upload any data to the clients Dropbox.
Now I would like to switch to owncloud because of some security concerns. I already have read this: Uploading files to an ownCloud server programatically
But unfortunately it didn't help.
I tried
curl -X PUT -u username:password "http://myserver.com/owncloud/remote.php/webdav/test" -F f=@"/tmp/test"
The file was uploaded, but there was a Problem: Some kind of Header was added to my file.
Original test-file:
test
Uploaded File:
--------------------------00c5e21306fd0b2d Content-Disposition: form-data; name="f"; filename="test" Content-Type: application/octet-stream
Dies ist ein Test.
--------------------------00c5e21306fd0b2d--
While this is really annoying on any text-Files it is a desaster on any binary files like JPGs etc, because they can't be opened any more after uploading.
That's why, I tried the other possible way, which was described:
mischka@lappy:/tmp$ curl -X PUT -u 'username:password' "http://myserver/owncloud/remote.php/webdav/test" --data-binary @"/tmp/test"
<?xml version="1.0" encoding="utf-8"?>
<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
<s:exception>Sabre\DAV\Exception\BadRequest</s:exception>
<s:message>expected filesize 19 got 0</s:message>
</d:error>
But the result was even worse!
Can anyone tell me, what I am doing wrong?
-F
means form upload, you should use --data-binary
instead:
curl -X PUT -u username:password
"http://myserver.com/owncloud/remote.php/webdav/test" --data-binary @"/tmp/test"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With