Skip to content

Commit 291c2ca

Browse files
update doc
Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com>
1 parent 3b1359e commit 291c2ca

1 file changed

Lines changed: 31 additions & 21 deletions

File tree

Sources/NextcloudKit/NextcloudKit+Upload.swift

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -167,27 +167,6 @@ public extension NextcloudKit {
167167
}
168168
}
169169

170-
/// - Parameters:
171-
/// - directory: Local input directory containing the original file.
172-
/// - fileChunksOutputDirectory: Optional output directory for produced chunks (defaults to `directory`).
173-
/// - fileName: Local file name to upload (input).
174-
/// - destinationFileName: Optional remote file name (defaults to `fileName`).
175-
/// - date: Optional remote mtime (modification time).
176-
/// - creationDate: Optional remote ctime (creation time).
177-
/// - serverUrl: Remote directory URL (WebDAV path without the file name).
178-
/// - chunkFolder: Remote temporary chunk folder name (e.g., UUID).
179-
/// - filesChunk: Optional precomputed chunk descriptors to reuse; if empty, chunks will be generated.
180-
/// - chunkSize: Desired chunk size in bytes.
181-
/// - account: Account identifier.
182-
/// - options: Request options (headers, timeout, etc.).
183-
/// - chunkProgressHandler: Reports per-chunk preparation progress (index/counter).
184-
/// - uploadStart: Called once when upload of chunks begins (with final list of chunks).
185-
/// - uploadTaskHandler: Exposes the low-level URLSessionTask.
186-
/// - uploadProgressHandler: Global progress callback (total file): (totalExpected, totalUploaded, fraction).
187-
/// - uploaded: Called after each chunk completes successfully.
188-
/// - assembling: Called just before remote assembly (MOVE .file -> destination).
189-
/// - Returns: (account, remainingChunks, NKFile?) where `remainingChunks == nil` on success.
190-
/// - Throws: NKError for any failure (including disk preflight and cancellations).
191170
actor ActorRequest {
192171
private var request: UploadRequest?
193172

@@ -207,6 +186,37 @@ public extension NextcloudKit {
207186
}
208187
}
209188

189+
/// Uploads a local file to a remote WebDAV endpoint using chunked upload.
190+
///
191+
/// The function optionally prepares chunk files (if `filesChunk` is empty),
192+
/// then uploads each chunk sequentially, reporting both per-chunk and
193+
/// global progress. After successful upload of all chunks, it triggers the
194+
/// remote assembly (e.g. MOVE of the temporary chunk file/folder to the
195+
/// final destination) and returns the final `NKFile` metadata if available.
196+
///
197+
/// - Parameters:
198+
/// - directory: Local input directory containing the original file.
199+
/// - fileChunksOutputDirectory: Optional output directory for produced chunks. If `nil`, `directory` is used.
200+
/// - fileName: Local file name to upload (input).
201+
/// - destinationFileName: Optional remote file name. If `nil`, `fileName` is used.
202+
/// - date: Optional remote modification time (mtime).
203+
/// - creationDate: Optional remote creation time (ctime).
204+
/// - serverUrl: Remote directory URL (WebDAV path without the file name).
205+
/// - chunkFolder: Remote temporary chunk folder name (for example, a UUID).
206+
/// - filesChunk: Precomputed chunk descriptors to reuse. Pass an empty array to generate chunks from the source file.
207+
/// - chunkSize: Desired chunk size in bytes.
208+
/// - account: Account identifier.
209+
/// - options: Request options (headers, timeout, etc.).
210+
/// - chunkProgressHandler: Reports per-chunk preparation progress as `(totalChunks, currentIndex)`.
211+
/// - uploadStart: Called once when upload of chunks begins, with the final list of chunks.
212+
/// - uploadTaskHandler: Exposes the low-level `URLSessionTask` for each chunk upload.
213+
/// - uploadProgressHandler: Global progress callback for the whole file: `(totalBytesExpected, totalBytesUploaded, fractionCompleted)`.
214+
/// - uploaded: Called after each chunk completes successfully, passing the corresponding chunk descriptor.
215+
/// - assembling: Called just before remote assembly (e.g. MOVE from temporary to final path).
216+
///
217+
/// - Returns: A tuple `(account, file)` where `account` is the account identifier used for the upload and `file` is the final `NKFile` metadata if available, otherwise `nil`.
218+
///
219+
/// - Throws: `NKError` for any failure (including disk preflight errors, network errors, server-side failures, or user cancellations).
210220
func uploadChunkAsync(directory: String,
211221
fileChunksOutputDirectory: String? = nil,
212222
fileName: String,

0 commit comments

Comments
 (0)