func canUnlock(as user: String) -> Bool {
return !lock || (lockOwner == user && lockOwnerType == 0)
}
+
+ func thumbnailUrl(size: CGSize) -> URL? {
+ guard hasPreview else {
+ return nil
+ }
+
+ let urlBase = urlBase.urlEncoded!
+ let webdavUrl = urlBase + NextcloudAccount.webDavFilesUrlSuffix + user // Leave the leading slash
+ let serverFileRelativeUrl = serverUrl.replacingOccurrences(of: webdavUrl, with: "") + "/" + fileName
+
+ let urlString = "\(urlBase)/index.php/core/preview.png?file=\(serverFileRelativeUrl)&x=\(size.width)&y=\(size.height)&a=1&mode=cover"
+
+ return URL(string: urlString)
+ }
}
import FileProvider
class NextcloudAccount: NSObject {
- private let webDavFilesUrlSuffix: String = "/remote.php/dav/files/"
+ static let webDavFilesUrlSuffix: String = "/remote.php/dav/files/"
let username, password, ncKitAccount, serverUrl, davFilesUrl: String
init(user: String, serverUrl: String, password: String) {
self.password = password
self.ncKitAccount = user + " " + serverUrl
self.serverUrl = serverUrl
- self.davFilesUrl = serverUrl + webDavFilesUrlSuffix + user
+ self.davFilesUrl = serverUrl + NextcloudAccount.webDavFilesUrlSuffix + user
super.init()
}