Skip to content

Commit a6d2137

Browse files
Merge branch 'main' into test-users
2 parents 489d8a7 + acc25f2 commit a6d2137

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

Sources/NextcloudKit/NextcloudKit+Share.swift

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ public extension NextcloudKit {
347347
password: String? = nil,
348348
expireDate: String? = nil,
349349
permissions: Int = 1,
350-
publicUpload: Bool = false,
350+
publicUpload: Bool? = nil,
351351
note: String? = nil,
352352
label: String? = nil,
353353
hideDownload: Bool,
@@ -365,24 +365,26 @@ public extension NextcloudKit {
365365
var parameters = [
366366
"permissions": String(permissions)
367367
]
368-
if let password = password {
368+
if let password, !password.isEmpty {
369369
parameters["password"] = password
370370
}
371-
if let expireDate = expireDate {
371+
if let expireDate, !expireDate.isEmpty {
372372
parameters["expireDate"] = expireDate
373373
}
374-
if let note = note {
374+
if let note, !note.isEmpty {
375375
parameters["note"] = note
376376
}
377-
if let label = label {
377+
if let label, !label.isEmpty {
378378
parameters["label"] = label
379379
}
380-
parameters["publicUpload"] = publicUpload ? "true" : "false"
380+
381+
if let publicUpload {
382+
parameters["publicUpload"] = publicUpload ? "true" : "false"
383+
}
384+
381385
parameters["hideDownload"] = hideDownload ? "true" : "false"
382386
if let attributes = attributes {
383387
parameters["attributes"] = attributes
384-
} else {
385-
parameters["attributes"] = "[]"
386388
}
387389

388390
nkSession.sessionData.request(url, method: .put, parameters: parameters, encoding: URLEncoding.default, headers: headers, interceptor: NKInterceptor(nkCommonInstance: nkCommonInstance)).validate(statusCode: 200..<300).onURLSessionTaskCreation { task in

0 commit comments

Comments
 (0)