@@ -15,6 +15,7 @@ public extension NextcloudKit {
1515 /// - dateCreationFile: Optional creation date to include in headers (X-OC-CTime).
1616 /// - dateModificationFile: Optional modification date to include in headers (X-OC-MTime).
1717 /// - overwrite: If true, the remote file will be overwritten if it already exists.
18+ /// - autoMkcol: When set to 1, instructs the server to automatically create any missing parent directories when uploading a file.
1819 /// - account: The account associated with the upload session.
1920 /// - options: Optional configuration for the request (headers, queue, timeout, etc.).
2021 /// - requestHandler: Called with the created UploadRequest.
@@ -33,6 +34,7 @@ public extension NextcloudKit {
3334 dateCreationFile: Date ? = nil ,
3435 dateModificationFile: Date ? = nil ,
3536 overwrite: Bool = false ,
37+ autoMkcol: Bool = false ,
3638 account: String ,
3739 options: NKRequestOptions = NKRequestOptions ( ) ,
3840 requestHandler: @escaping ( _ request: UploadRequest ) -> Void = { _ in } ,
@@ -64,8 +66,13 @@ public extension NextcloudKit {
6466 if overwrite {
6567 headers. update ( name: " Overwrite " , value: " true " )
6668 }
69+ if autoMkcol {
70+ headers. update ( name: " X-NC-WebDAV-Auto-Mkcol " , value: " 1 " )
71+ }
6772 headers. update ( . contentType( " application/octet-stream " ) )
6873
74+ // X-NC-WebDAV-Auto-Mkcol
75+
6976 let request = nkSession. sessionData. upload ( fileNameLocalPathUrl, to: url, method: . put, headers: headers, interceptor: NKInterceptor ( nkCommonInstance: nkCommonInstance) , fileManager: . default) . validate ( statusCode: 200 ..< 300 ) . onURLSessionTaskCreation ( perform: { task in
7077 task. taskDescription = options. taskDescription
7178 options. queue. async { taskHandler ( task) }
@@ -104,17 +111,7 @@ public extension NextcloudKit {
104111
105112 /// Asynchronously uploads a file to the Nextcloud server.
106113 ///
107- /// - Parameters:
108- /// - serverUrlFileName: The remote server URL or path where the file will be uploaded.
109- /// - fileNameLocalPath: The local file path to be uploaded.
110- /// - dateCreationFile: Optional creation date to include in headers (X-OC-CTime).
111- /// - dateModificationFile: Optional modification date to include in headers (X-OC-MTime).
112- /// - overwrite: If true, the remote file will be overwritten if it already exists.
113- /// - account: The account associated with the upload session.
114- /// - options: Optional configuration for the request (headers, queue, timeout, etc.).
115- /// - requestHandler: Called with the created UploadRequest.
116- /// - taskHandler: Called with the underlying URLSessionTask when it's created.
117- /// - progressHandler: Called periodically with upload progress.
114+ /// - Parameters: Same as the synchronous version.
118115 ///
119116 /// - Returns: A tuple containing:
120117 /// - account: The account used for the upload.
@@ -129,6 +126,7 @@ public extension NextcloudKit {
129126 dateCreationFile: Date ? = nil ,
130127 dateModificationFile: Date ? = nil ,
131128 overwrite: Bool = false ,
129+ autoMkcol: Bool = false ,
132130 account: String ,
133131 options: NKRequestOptions = NKRequestOptions ( ) ,
134132 requestHandler: @escaping ( _ request: UploadRequest ) -> Void = { _ in } ,
@@ -149,6 +147,7 @@ public extension NextcloudKit {
149147 dateCreationFile: dateCreationFile,
150148 dateModificationFile: dateModificationFile,
151149 overwrite: overwrite,
150+ autoMkcol: autoMkcol,
152151 account: account,
153152 options: options,
154153 requestHandler: requestHandler,
0 commit comments