|
@@ -45,20 +45,26 @@ extension FileProviderExtension {
|
|
|
let fileNamePath = CCUtility.returnFileNamePath(fromFileName: metadata.fileName, serverUrl: metadata.serverUrl, urlBase: metadata.urlBase, account: metadata.account)!
|
|
|
let fileNameIconLocalPath = CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag)!
|
|
|
|
|
|
- NCCommunication.shared.getPreview(fileNamePath: fileNamePath, widthPreview: NCGlobal.shared.sizeIcon, heightPreview: NCGlobal.shared.sizeIcon) { _, data, errorCode, _ in
|
|
|
- if errorCode == 0 && data != nil {
|
|
|
- do {
|
|
|
- try data!.write(to: URL(fileURLWithPath: fileNameIconLocalPath), options: .atomic)
|
|
|
- } catch { }
|
|
|
- perThumbnailCompletionHandler(itemIdentifier, data, nil)
|
|
|
- } else {
|
|
|
- perThumbnailCompletionHandler(itemIdentifier, nil, NSFileProviderError(.serverUnreachable))
|
|
|
- }
|
|
|
- counterProgress += 1
|
|
|
- if counterProgress == progress.totalUnitCount {
|
|
|
- completionHandler(nil)
|
|
|
+ if let urlBase = metadata.urlBase.urlEncoded,
|
|
|
+ let fileNamePath = fileNamePath.urlEncoded,
|
|
|
+ let url = URL(string: "\(urlBase)/index.php/core/preview.png?file=\(fileNamePath)&x=\(size)&y=\(size)&a=1&mode=cover") {
|
|
|
+
|
|
|
+ NCCommunication.shared.getPreview(url: url) { _, data, errorCode, _ in
|
|
|
+ if errorCode == 0 && data != nil {
|
|
|
+ do {
|
|
|
+ try data!.write(to: URL(fileURLWithPath: fileNameIconLocalPath), options: .atomic)
|
|
|
+ } catch { }
|
|
|
+ perThumbnailCompletionHandler(itemIdentifier, data, nil)
|
|
|
+ } else {
|
|
|
+ perThumbnailCompletionHandler(itemIdentifier, nil, NSFileProviderError(.serverUnreachable))
|
|
|
+ }
|
|
|
+ counterProgress += 1
|
|
|
+ if counterProgress == progress.totalUnitCount {
|
|
|
+ completionHandler(nil)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
} else {
|
|
|
counterProgress += 1
|
|
|
if counterProgress == progress.totalUnitCount {
|