Hi, I’m writing an app that uploads pictures to my ownCloud server with the File Transfer Plugin which internally uses a PUT request. Here is the relevant part of my code:
import {Transfer} from "ionic-native";
...
upload(imgToUpload) {
let transfer = new Transfer();
let URL: "https://username:password@owncloud.../remote.php/webdav/folder/"
let options = {
httpMethod: "PUT"
}
transfer.upload(imgToUpload, URL, options, true).then(
(succ) => {},
(err) => {console.log(err.http_status+" "+err.body);}
);
}
The whole thing works on Android, but on iOS get the following error from ownCloud:
401 <?xml version="1.0" encoding="utf-8"?>
<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
<s:exception>Sabre\DAV\Exception\NotAuthenticated</s:exception>
<s:message>Cannot authenticate over ajax calls</s:message>
</d:error>
It seems that the error originates here in the ownCloud source code. Apparently the File Transfer Plugin adds the X-Requested-With: XMLHttpRequest header, but I don’t understand why this only happens on iOS and not on Android.
Does anyone know how to fix this?
Thanks in advance!