iOS library - Cannot upload to server

Hi,
I'm new with ownCloud, sorry if my post does not mach with selected category.
I'm developing an iOS app that can login and upload some media file to my ownCloud server.
The server is good, I can login, share and upload files, same with Android.

But with iOS app, although I can do authentication successfully, when I tried to upload audio file (ex: wav), I always receive error 405, which means don't have permission.
Please help me if you have any comment.
Thank you very much.

Here is my demo source code
1. For authentication
static NSString *BASE_URL = @"https://xxx.xxx.xxx/";

  • (OCCommunication *)ocCommunication
    {
    if (!_ocCommunication) {
    NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:k_session_name];
    configuration.HTTPMaximumConnectionsPerHost = 1;
    configuration.requestCachePolicy = NSURLRequestUseProtocolCachePolicy;
    configuration.timeoutIntervalForRequest = k_timeout_upload;
    configuration.sessionSendsLaunchEvents = YES;
    [configuration setAllowsCellularAccess:YES];
    AFURLSessionManager *uploadSessionManager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration];
    [uploadSessionManager.operationQueue setMaxConcurrentOperationCount:1];
    [uploadSessionManager setSessionDidReceiveAuthenticationChallengeBlock:^NSURLSessionAuthChallengeDisposition (NSURLSession *session, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential) {
    return NSURLSessionAuthChallengePerformDefaultHandling;
    }];

    NSURLSessionConfiguration *configurationDownload = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:k_download_session_name];
    configurationDownload.HTTPMaximumConnectionsPerHost = 1;
    configurationDownload.requestCachePolicy = NSURLRequestUseProtocolCachePolicy;
    configurationDownload.timeoutIntervalForRequest = k_timeout_upload;
    configurationDownload.sessionSendsLaunchEvents = YES;
    [configurationDownload setAllowsCellularAccess:YES];
    AFURLSessionManager *downloadSessionManager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configurationDownload];
    [downloadSessionManager.operationQueue setMaxConcurrentOperationCount:1];
    [downloadSessionManager setSessionDidReceiveAuthenticationChallengeBlock:^NSURLSessionAuthChallengeDisposition (NSURLSession *session, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential) {
        return NSURLSessionAuthChallengePerformDefaultHandling;
    }];
    
    NSURLSessionConfiguration *networkConfiguration = [NSURLSessionConfiguration defaultSessionConfiguration];
    networkConfiguration.HTTPShouldUsePipelining = YES;
    networkConfiguration.HTTPMaximumConnectionsPerHost = 1;
    networkConfiguration.requestCachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
    AFURLSessionManager *networkSessionManager = [[AFURLSessionManager alloc] initWithSessionConfiguration:networkConfiguration];
    [networkSessionManager.operationQueue setMaxConcurrentOperationCount:1];
    networkSessionManager.responseSerializer = [AFHTTPResponseSerializer serializer];
    
    _ocCommunication = [[OCCommunication alloc] initWithUploadSessionManager:uploadSessionManager andDownloadSessionManager:downloadSessionManager andNetworkSessionManager:networkSessionManager];
    [_ocCommunication setIsCookiesAvailable:YES];
    [_ocCommunication setUserAgent:self.userAgent];
    OCCredentialsDto *ocCredentialsDto = [[OCCredentialsDto alloc] init];
    ocCredentialsDto.userName = @"xxx";
    ocCredentialsDto.accessToken = @"xxx";
    ocCredentialsDto.baseURL = BASE_URL;
    ocCredentialsDto.authenticationMethod = AuthenticationMethodBASIC_HTTP_AUTH;
    [_ocCommunication setCredentials:ocCredentialsDto];
}
return _ocCommunication;

}

  • (NSString *)userAgent {
    if (!_userAgent) {
    _userAgent = [NSString stringWithFormat:@"%@/%@ (%@; iOS %@; Scale/%0.2f)", [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleExecutableKey] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleIdentifierKey], [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleVersionKey], [[UIDevice currentDevice] model], [[UIDevice currentDevice] systemVersion], [[UIScreen mainScreen] scale]];
    }
    return _userAgent;
    }
  1. Upload media file
    • (void)uploadFile:(NSString *)filePath toServer:(NSString *)serverPath
      {
      NSString *uploadPath = [[NSString stringWithFormat:@"%@%@", BASE_URL, serverPath] stringByRemovingPercentEncoding];
      [self.ocCommunication uploadFileSession:filePath
      toDestiny:uploadPath
      onCommunication:self.ocCommunication
      progress:^(NSProgress *progress) {
      }
      successRequest:^(NSURLResponse *response, NSString *redirectedServer) {
      }
      failureRequest:^(NSURLResponse *response, NSString *redirectedServer, NSError *error) {
      }
      failureBeforeRequest:^(NSError *error) {
      }];
      }

Here is my error log:

{ URL: https://xxx.xxx.xxx/index.php/apps/files/ } { Status Code: 405, Headers {
"Cache-Control" = (
"no-store, no-cache, must-revalidate, post-check=0, pre-check=0"
);
Connection = (
"keep-alive"
);
"Content-Security-Policy" = (
"default-src 'self'; script-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; frame-src *; img-src * data: blob:; font-src 'self' data:; media-src *; connect-src *"
);
"Content-Type" = (
"text/html; charset=UTF-8"
);
Date = (
"Tue, 21 Nov 2017 04:14:53 GMT"
);
Expires = (
"Thu, 19 Nov 1981 08:52:00 GMT"
);
Pragma = (
"no-cache"
);
Server = (
"nginx/1.12.1"
);
"Set-Cookie" = (
"oclpmrl9msf6=t8b4me9k1iamheu625lqrbmh46; path=/; HttpOnly",
"oc_sessionPassphrase=2BOfcEKrcD3dVi%2FrhmRlTcNipcOVfyMoVSW6Mjnbo8I24L170GNfVO2vQYYUGTBGo01JLK5GYn9wF4NxeJ5SMjuwzgtGQ4xiatzQpXYYKE8H3xOb6Wh64fYAevqf8I03; path=/; secure; httponly"
);
"Transfer-Encoding" = (
Identity
);
"X-Powered-By" = (
"PHP/5.6.31"
);
} }